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.
66 // For access to DOM2 core
68 // For access to DOM2 events
70 // For access to those parts from DOM2 CSS OM used by SVG DOM.
72 // For access to those parts from DOM2 Views OM used by SVG DOM.
74 // For access to the SMIL OM used by SVG DOM.
76 #pragma prefix "dom.w3c.org"
77 #pragma javaPackage "org.w3c.dom"
80 typedef dom::DOMString DOMString;
81 typedef dom::DOMException DOMException;
82 typedef dom::Element Element;
83 typedef dom::Document Document;
84 typedef dom::NodeList NodeList;
87 interface SVGLangSpace;
88 interface SVGExternalResourcesRequired;
90 interface SVGFitToViewBox;
91 interface SVGZoomAndPan;
92 interface SVGViewSpec;
93 interface SVGURIReference;
96 interface SVGPreserveAspectRatio;
97 interface SVGAnimatedPreserveAspectRatio;
98 interface SVGTransformList;
99 interface SVGAnimatedTransformList;
100 interface SVGTransform;
101 interface SVGICCColor;
104 interface SVGTransformable;
105 interface SVGDocument;
106 interface SVGSVGElement;
107 interface SVGElementInstance;
108 interface SVGElementInstanceList;
110 function SVGException(code) {
111 /*unsigned short*/ this.code = code;
112 if (this.code === SVGException.SVG_WRONG_TYPE_ERR) {
113 this.message = "SVG Wrong Type Error";
114 } else if (this.code === SVGException.SVG_INVALID_VALUE_ERR) {
115 this.message = "SVG Invalid Value Error";
116 } else if (this.code === SVGException.SVG_MATRIX_NOT_INVERTABLE) {
117 this.message = "SVG Matrix Not Invertable";
121 SVGException.constructor = Error;
122 SVGException.prototype = new Error();
124 /*const unsigned short*/ SVGException.SVG_WRONG_TYPE_ERR = 0;
125 /*const unsigned short*/ SVGException.SVG_INVALID_VALUE_ERR = 1;
126 /*const unsigned short*/ SVGException.SVG_MATRIX_NOT_INVERTABLE = 2;
129 *すべてのSVG関連要素の雛形となるオブジェクト
131 function SVGElement() {
133 SVGStylable.call(this); //ElementCSSInlineStyleのインタフェースを継承
134 /*interface SVGTransformable : SVGLocatable
135 *TransformListはtransform属性を行列で表現したあとのリスト構造
137 /*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
138 //描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
139 this.addEventListener("DOMAttrModified", function(evt){
140 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
143 var name = evt.attrName,
145 if (!!CSS2Properties[name] || (name.indexOf("-") > -1)) { //スタイルシートのプロパティならば
146 tar._attributeStyle.setProperty(name, evt.newValue, "");
148 if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
149 tar.id = evt.newValue;
150 } else if ((name === "transform") && !!tar.transform) {
151 var tft = evt.newValue,
153 coma = tft.match(tar._comaReg), //コマンド文字にマッチ translate
154 list = tft.match(tar._strReg), //カッコ内のリストにマッチ (10 20 30...)
164 etod = evt.target.ownerDocument.documentElement,
165 ttb = tar.transform.baseVal;
166 //transform属性の値を、SVGTransformListであるtransformプロパティに結びつける
167 for (var j=0,cli=coma.length;j<cli;j++) {
168 s = etod.createSVGTransform();
171 deg = lis.match(degR);
184 s.setRotate(degz, +(deg[1]), +(deg[2]))
185 } else if (degli <= 2) {
187 if (com === "translate") {
188 s.setTranslate(degz, +(deg[1] || 0));
189 } else if (com === "scale") {
190 s.setScale(degz, +(deg[1] || deg[0]));
191 } else if (com === "rotate") {
192 s.setRotate(degz, 0, 0);
193 } else if (com === "skewX") {
195 } else if (com === "skewY") {
202 tft = degR = coma = list = a = b = c = d = e = f = lis = com = deg = rad = degli = s = cm = degz = etod = ttb = void 0;
203 } else if (name === "style") {
204 var sc = evt.newValue,
212 sc = sc.replace(tar._shouReg, "")
213 .replace(tar._conReg, ":")
214 .replace(tar._bouReg, ";");
216 for (var i=0, ali=a.length;i<ali;++i) {
220 style.setProperty(m[0], m[1]);
225 a = sc = style = void 0;
226 } else if (name === "class") {
227 tar.className = evt.newValue;
228 } else if (name.indexOf("on") === 0) { //event属性ならば
229 /*ECMA 262-3においては、eval("(function(){})")はFunctionオブジェクトを返さなければならない
230 *ところが、IEでは、undefinedの値を返してしまう。
231 *他のブラウザではECMAの仕様にしたがっているようなので、IEだけの問題であることに注意
233 eval("document._s = (function(evt){" +evt.newValue+ "})");
234 var v = name.slice(2);
237 } else if (v === "unload") {
239 } else if (v === "abort") {
241 } else if (v === "error") {
243 } else if (v === "resize") {
245 } else if (v === "scroll") {
247 } else if (v === "zoom") {
249 } else if (v === "begin") {
251 } else if (v === "end") {
253 } else if (v === "repeat") {
256 tar.addEventListener(v, document._s, false);
257 } else if (evt.relatedNode.nodeName === "xml:base") { //xml:base属性ならば
258 tar.xmlbase = evt.newValue;
259 } else if (!!tar[name] && (tar[name] instanceof SVGAnimatedLength)) {
261 tod = tar.ownerDocument.documentElement,
262 tvw = tod.viewport.width,
263 tvh = tod.viewport.height,
265 n = evt.newValue.slice(-2),
267 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1,
268 _parseFloat = parseFloat;
269 if (m >= "0" && m <= "9") { //軽量化のためにチェックを設ける
270 } else if (m === "%") {
271 if (tar._x1width[name]) {
272 tea.baseVal._percent = tvw * 0.01;
273 } else if (tar._y1height[name]) {
274 tea.baseVal._percent = tvh * 0.01;
276 tea.baseVal._percent = Math.sqrt((tvw*tvw + tvh*tvh) / 2) * 0.01;
278 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
279 } else if (n === "em") {
280 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
281 } else if (n === "ex") {
282 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
283 } else if (n === "px") {
284 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
285 } else if (n === "cm") {
286 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
287 } else if (n === "mm") {
288 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
289 } else if (n === "in") {
290 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
291 } else if (n === "pt") {
292 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
293 } else if (n === "pc") {
294 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
296 s = _parseFloat(evt.newValue);
297 s = isNaN(s) ? 0 : s;
298 tea.baseVal.newValueSpecifiedUnits(type, s);
299 tea = tod = tvw = tvh = n = type = _parseFloat = s = void 0;
301 evt = _parseFloat = name = tar = null;
305 SVGElement.constructor = Element;
306 SVGElement.prototype = new Element();
309 /*以下の正規表現は属性のパーサの際に用いる*/
310 this._degReg = /[\-\d\.e]+/g;
311 this._comaReg = /[A-Za-z]+(?=\s*\()/g;
312 this._strReg = /\([^\)]+\)/g;
313 this._syouReg = /^[^a-z\-]+/;
314 this._conReg = /\:\s+/g;
315 this._bouReg = /\s*;[^a-z\-]*/g;
316 /*_cacheMatrixプロパティはSVGMatrixのキャッシュとして、
319 this._cacheMatrix = null;
320 /*以下のオブジェクトは単位がパーセント付きの属性の名前を示し、処理に使う*/
335 /*String*/ this.id = null; //id属性の値
336 /*String*/ this.xmlbase = null; //xml:base属性の値
337 /*SVGSVGElement*/ this.ownerSVGElement; //ルート要素であるsvg要素
338 /*readonly SVGElement*/ this.viewportElement; //ビューポートを形成する要素(多くはsvg要素)
339 /*readonly attribute SVGElement*/ this.nearestViewportElement = null;
340 /*readonly attribute SVGElement*/ this.farthestViewportElement = null;
342 /*interface SVGLocatable*/
343 /*SVGRect*/ this.getBBox = function(){
344 var s = new SVGRect(),
345 data = this._tar.path.value,
346 vi = this.ownerDocument.documentElement.viewport,
351 degis = data.match(/[0-9\-]+/g),
354 /*要素の境界領域を求める(四隅の座標を求める)
355 *etは境界領域の上からビューポート(例えばsvg要素)の上端までの距離であり、ebは境界領域の下からビューポートの下端までの距離
356 *elは境界領域の左からビューポートの左端までの距離であり、erは境界領域の右からビューポートの右端までの距離
358 for (var i=0,degisli=degis.length;i<degisli;i+=2) {
361 el = el > nx ? nx : el;
362 et = et > ny ? ny : et;
363 er = er > nx ? er : nx;
364 eb = eb > ny ? eb : ny;
370 nx = ny = data = degis =el = et = er = eb = vi = void 0;
375 *CTMとは現在の利用座標系に対する変換行列
376 *注意点として、SVG1.1とSVG Tiny1.2では内容が異なる。たとえば、
377 *1.2ではgetCTMが言及されていない
378 *もし、要素の中心座標を取得したい人がいれば、transformプロパティのconsolidateメソッドを使うこと
380 /*SVGMatrix*/ this.getCTM = function() {
382 if (!!this._cacheMatrix) { //キャッシュがあれば
383 s = this._cacheMatrix;
385 m = this.transform.baseVal.consolidate();
389 m = this.ownerDocument.documentElement.createSVGMatrix();
391 if (this.parentNode && !!this.parentNode.getCTM) {
392 s = this.parentNode.getCTM().multiply(m);
397 this._cacheMatrix = s; //キャッシュをためて次回で使う
402 /*SVGMatrix*/ this.getScreenCTM = function(){
403 if (!this.parentNode) {
406 var view = this.nearestViewportElement || this.ownerDocument.documentElement;
407 var s = view.getScreenCTM().multiply(this.getCTM());
412 /*getTransformToElementメソッド
413 *これは、あるelementへの変換行列を計算して返す
414 *たとえばある要素から別の要素への引越しをする際の変換行列を算出することが可能
416 /*SVGMatrix*/ this.getTransformToElement = function(/*SVGElement*/ element ){
417 var s = this.getScreenCTM().inverse().multiply(element.getScreenCTM());
420 }).apply(SVGElement.prototype);
422 function SVGAnimatedBoolean() {
423 /*boolean*/ this.animVal = this.baseVal = true;
427 function SVGAnimatedString() {
428 /*String*/ this.animVal = this.baseVal = "";
432 function SVGStringList() {
435 SVGStringList.prototype = new Array();
437 /*readonly unsigned long*/ this.numberOfItems = 0;
438 /*void*/ this.clear = function(){
439 for (var i=0, tli=this.length;i<tli;++i) {
442 this.numberOfItems = 0;
444 /*DOMString*/ this.initialize = function(/*DOMString*/ newItem ) {
447 this.numberOfItems = 1;
450 /*DOMString*/ this.getItem = function(/*unsigned long*/ index ) {
451 if (index >= this.numberOfItems || index < 0) {
452 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
454 return (this[index]);
457 /*DOMString*/ this.insertItemBefore = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
458 if (index >= this.numberOfItems) {
459 this.appendItem(newItem);
461 this.splice(index, 1, newItem, this.getItem[index]);
462 ++this.numberOfItems;
466 /*DOMString*/ this.replaceItem = function(/*DOMString*/ newItem, /*unsigned long*/ index ){
467 if (index >= this.numberOfItems || index < 0) {
468 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
470 this.splice(index, 1, newItem);
474 //raises( DOMException, SVGException );
475 /*DOMString*/ this.removeItem = function(/*unsigned long*/ index ){
476 if (index >= this.numberOfItems || index < 0) {
477 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
479 this.splice(index, 1);
480 --this.numberOfItems;
484 /*DOMString*/ this.appendItem = function(/*DOMString*/ newItem ){
485 this[this.numberOfItems] = newItem;
486 ++this.numberOfItems;
488 }).apply(SVGStringList.prototype);
490 function SVGAnimatedEnumeration() {
491 /*unsigned short*/ this.baseVal = 0;
492 // raises DOMException on setting
493 /*readonly unsigned short*/ this.animVal = 0;
496 function SVGAnimatedInteger() {
497 /*long*/ this.baseVal = 0;
498 // raises DOMException on setting
499 /*readonly long*/ this.animVal = 0;
502 function SVGNumber() {
503 /*float*/ this.value = 0;
504 // raises DOMException on setting
507 function SVGAnimatedNumber() {
508 /*float*/ this.baseVal = this.animVal = 0;
512 function SVGNumberList() {
515 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
516 SVGNumberList.prototype[prop] = SVGStringList.prototype[prop];
518 function SVGAnimatedNumberList() {
519 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGNumberList();
523 *長さを設定する(単位pxに統一する方便として使う)
524 *valueInSpecifiedUnitsプロパティはpxに統一する前の数値。valueプロパティはpxに統一した後の数値
526 function SVGLength() {
531 /*const unsigned short*/ t.SVG_LENGTHTYPE_UNKNOWN = 0;
532 /*const unsigned short*/ t.SVG_LENGTHTYPE_NUMBER = 1;
533 /*const unsigned short*/ t.SVG_LENGTHTYPE_PERCENTAGE = 2;
534 /*const unsigned short*/ t.SVG_LENGTHTYPE_EMS = 3;
535 /*const unsigned short*/ t.SVG_LENGTHTYPE_EXS = 4;
536 /*const unsigned short*/ t.SVG_LENGTHTYPE_PX = 5;
537 /*const unsigned short*/ t.SVG_LENGTHTYPE_CM = 6;
538 /*const unsigned short*/ t.SVG_LENGTHTYPE_MM = 7;
539 /*const unsigned short*/ t.SVG_LENGTHTYPE_IN = 8;
540 /*const unsigned short*/ t.SVG_LENGTHTYPE_PT = 9;
541 /*const unsigned short*/ t.SVG_LENGTHTYPE_PC = 10;
544 SVGLength.prototype = {
545 /*readonly attribute unsigned short*/ unitType : SVGLength.SVG_LENGTHTYPE_UNKNOWN,
546 /*attribute float*/ value : 0, //利用単位における値
547 /*attribute float*/ valueInSpecifiedUnits : SVGLength.SVG_LENGTHTYPE_UNKNOWN, //unitTypeにおける値
548 /*attribute DOMString*/ valueAsString : "0",
549 _percent : 0.01, //単位に%が使われていた場合、このプロパティの数値を1%として使う
550 _fontSize : 12, //単位のemとexで使われるfont-sizeの値
551 /*newValueSpedifiedUnitsメソッド
552 *新しくunitTypeにおける値を設定する
553 *例:2pxならば、x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_PX, 2);となる
555 newValueSpecifiedUnits : function (/*unsigned short*/ unitType, /*float*/ valueInSpecifiedUnits) {
557 _s = ""; //nは各単位から利用単位への変換数値。_sは単位の文字列を表す
558 if (unitType === /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1) {
559 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PX*/ 5) {
561 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2) {
564 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) {
567 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4) {
568 n = this._fontSize * 0.5;
570 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_CM*/ 6) {
573 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_MM*/ 7) {
576 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_IN*/ 8) {
579 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PT*/ 9) {
582 } else if (unitType === /*SVGLength.SVG_LENGTHTYPE_PC*/ 10) {
586 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
588 this.unitType = unitType;
589 this.value = valueInSpecifiedUnits * n;
590 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
591 this.valueAsString = valueInSpecifiedUnits + _s;
592 valueInSpecifiedUnits = unitType = n = _s = void 0;
594 /*convertToSpecifiedUnitsメソッド
595 *valueプロパティを書き換えずに、単位だけを変換する
597 * x.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_CM, 2);
598 * x.convertToSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_MM);
599 * alert(x.valueAsString); //20mm
601 convertToSpecifiedUnits : function (/*unsigned short*/ unitType) {
602 if (this.value === 0) {
603 this.newValueSpecifiedUnits(unitType, 0);
607 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
608 v = v / this.value * this.valueInSpecifiedUnits;
609 this.newValueSpecifiedUnits(unitType, v);
612 *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる
613 *単位が%の場合は、新しいvalueへと変換させておく
615 _emToUnit : function (/*float*/ fontSize) {
616 if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) {
617 this._fontSize = fontSize;
618 this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits);
622 function SVGAnimatedLength() {
623 /*readonly SVGLength*/ this.animVal;
624 this.baseVal = new SVGLength();
625 this.baseVal.unitType = 1;
628 function SVGLengthList() {
631 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
632 SVGLengthList.prototype[prop] = SVGStringList.prototype[prop];
634 function SVGAnimatedLengthList() {
635 /*readonly SVGNumberList*/ this.animVal = this.baseVal = new SVGLengthList();
638 function SVGAngle() {
641 SVGAngle.prototype = {
642 /*readonly attribute unsigned short*/ unitType : 0,
643 /*attribute float*/ value : 0,
644 // raises DOMException on setting
645 /*attribute float*/ valueInSpecifiedUnits : 0,
646 // raises DOMException on setting
647 /*attribute DOMString*/ valueAsString : "0",
648 // raises DOMException on setting
649 /*void*/ newValueSpecifiedUnits : function (/*in unsigned short*/ unitType, /*in float*/ valueInSpecifiedUnits ) {
651 _s = ""; //nは各単位から度への変換数値。_sは単位の文字列を表す
652 if (unitType === SVGAngle.SVG_ANGLETYPE_UNSPECIFIED) {
653 } else if (unitType === SVGAngle.SVG_ANGLETYPE_DEG) {
655 } else if (unitType === SVGAngle.SVG_ANGLETYPE_RAD) {
658 } else if (unitType === SVGAngle.SVG_ANGLETYPE_GRAD) {
662 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
664 this.unitType = unitType;
665 this.value = valueInSpecifiedUnits * n;
666 this.valueInSpecifiedUnits = valueInSpecifiedUnits;
667 this.valueAsString = valueInSpecifiedUnits + _s;
669 //raises( DOMException );
671 /*void*/ convertToSpecifiedUnits : function (/*in unsigned short*/ unitType ) {
672 if (this.value === 0) {
673 this.newValueSpecifiedUnits(unitType, 0);
677 this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits);
678 v = v / this.value * this.valueInSpecifiedUnits;
679 this.newValueSpecifiedUnits(unitType, v);
680 //raises( DOMException );
684 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNKNOWN = 0;
685 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_UNSPECIFIED = 1;
686 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_DEG = 2;
687 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_RAD = 3;
688 /*const unsigned short*/ SVGAngle.SVG_ANGLETYPE_GRAD = 4;
689 function SVGAnimatedAngle() {
690 /*readonly attribute SVGAngle*/ this.baseVal = new SVGAngle();
691 /*readonly attribute SVGAngle*/ this.animVal = this.baseVal;
694 function SVGColor() {
695 CSSValue.apply(this);
696 /*readonly css::RGBColor*/ this.rgbColor = new RGBColor();
701 /*unsigned short*/ SVGColor.SVG_COLORTYPE_UNKNOWN = 0;
702 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR = 1;
703 /*unsigned short*/ SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR = 2;
704 /*unsigned short*/ SVGColor.SVG_COLORTYPE_CURRENTCOLOR = 3;
705 SVGColor.prototype = new CSSValue(); //ノードのプロトタイプチェーンを作って、継承
706 SVGColor.constructor = CSSValue;
709 /*readonly unsigned short*/ this.colorType = /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0;
710 /*readonly SVGICCColor*/ this.iccColor = null;
712 this._regDP = /[\d.]+%/g;
713 /*void*/ this.setRGBColor = function(/*DOMString*/ rgbColor ){
718 if (!rgbColor || (typeof rgbColor !== "string")) {
719 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
721 rgbColor = this._keywords[rgbColor] || rgbColor;
722 if (rgbColor.indexOf("%", 5) > 0) { // %を含むrgb形式の場合
723 rgbColor = rgbColor.replace(this._regDP, function(s) {
724 return Math.round((2.55 * parseFloat(s)));
726 s = rgbColor.match(this._regD);
727 } else if (rgbColor.indexOf("#") === 0) { //#を含む場合
729 _parseInt = parseInt;
730 r = rgbColor.charAt(1);
731 g = rgbColor.charAt(2);
732 b = rgbColor.charAt(3)
733 if (rgbColor.length < 5) {
734 c = "#" + r + r + g + g + b + b;
738 s[0] = _parseInt(r+rgbColor.charAt(2), 16)+ "";
739 s[1] = _parseInt(rgbColor.charAt(3)+rgbColor.charAt(4), 16)+ "";
740 s[2] = _parseInt(rgbColor.charAt(5)+rgbColor.charAt(6), 16)+ "";
743 s = rgbColor.match(this._regD);
744 if (!s || (s.length < 3)) { //数値が含まれていなければ強制的に終了
746 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
749 this.rgbColor.red.setFloatValue(/*CSSPrimitiveValue.CSS_NUMBER*/ 1, s[0]);
750 this.rgbColor.green.setFloatValue(1, s[1]);
751 this.rgbColor.blue.setFloatValue(1, s[2]);
752 rgbColor = s = _parseInt = void 0;
755 // raises( SVGException );
756 /*void*/ this.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){
757 this.colorType = colorType;
758 if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) && iccColor) {
759 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
760 } else if (colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR*/ 1) {
761 this.setRGBColor(rgbColor);
762 } else if (rgbColor && (colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
763 this.setRGBColor(rgbColor);
764 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_UNKNOWN*/ 0) && (rgbColor || iccColor)) {
765 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
766 } else if ((colorType === /*SVGColor.SVG_COLORTYPE_RGBCOLOR_ICCCOLOR*/ 2) && (rgbColor || !iccColor)) {
767 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
769 colorType = rgbColor = void 0;
771 // raises( SVGException );
774 aliceblue: "rgb(240,248,255)",
775 antiquewhite: "rgb(250,235,215)",
776 aqua: "rgb(0,255,255)",
777 aquamarine: "rgb(127,255,212)",
778 azure: "rgb(240,255,255)",
779 beige: "rgb(245,245,220)",
780 bisque: "rgb(255,228,196)",
782 blanchedalmond:"rgb(255,235,205)",
783 blue: "rgb(0,0,255)",
784 blueviolet: "rgb(138,43,226)",
785 brown: "rgb(165,42,42)",
786 burlywood: "rgb(222,184,135)",
787 cadetblue: "rgb(95,158,160)",
788 chartreuse: "rgb(127,255,0)",
789 chocolate: "rgb(210,105,30)",
790 coral: "rgb(255,127,80)",
791 cornflowerblue:"rgb(100,149,237)",
792 cornsilk: "rgb(255,248,220)",
793 crimson: "rgb(220,20,60)",
794 cyan: "rgb(0,255,255)",
795 darkblue: "rgb(0,0,139)",
796 darkcyan: "rgb(0,139,139)",
797 darkgoldenrod:"rgb(184,134,11)",
798 darkgray: "rgb(169,169,169)",
799 darkgreen: "rgb(0,100,0)",
800 darkgrey: "rgb(169,169,169)",
801 darkkhaki: "rgb(189,183,107)",
802 darkmagenta: "rgb(139,0,139)",
803 darkolivegreen:"rgb(85,107,47)",
804 darkorange: "rgb(255,140,0)",
805 darkorchid: "rgb(153,50,204)",
806 darkred: "rgb(139,0,0)",
807 darksalmon: "rgb(233,150,122)",
808 darkseagreen: "rgb(143,188,143)",
809 darkslateblue:"rgb(72,61,139)",
810 darkslategray:"rgb(47,79,79)",
811 darkslategrey:"rgb(47,79,79)",
812 darkturquoise:"rgb(0,206,209)",
813 darkviolet: "rgb(148,0,211)",
814 deeppink: "rgb(255,20,147)",
815 deepskyblue: "rgb(0,191,255)",
816 dimgray: "rgb(105,105,105)",
817 dimgrey: "rgb(105,105,105)",
818 dodgerblue: "rgb(30,144,255)",
819 firebrick: "rgb(178,34,34)",
820 floralwhite: "rgb(255,250,240)",
821 forestgreen: "rgb(34,139,34)",
822 fuchsia: "rgb(255,0,255)",
823 gainsboro: "rgb(220,220,220)",
824 ghostwhite: "rgb(248,248,255)",
825 gold: "rgb(255,215,0)",
826 goldenrod: "rgb(218,165,32)",
827 gray: "rgb(128,128,128)",
828 grey: "rgb(128,128,128)",
829 green: "rgb(0,128,0)",
830 greenyellow: "rgb(173,255,47)",
831 honeydew: "rgb(240,255,240)",
832 hotpink: "rgb(255,105,180)",
833 indianred: "rgb(205,92,92)",
834 indigo: "rgb(75,0,130)",
835 ivory: "rgb(255,255,240)",
836 khaki: "rgb(240,230,140)",
837 lavender: "rgb(230,230,250)",
838 lavenderblush:"rgb(255,240,245)",
839 lawngreen: "rgb(124,252,0)",
840 lemonchiffon: "rgb(255,250,205)",
841 lightblue: "rgb(173,216,230)",
842 lightcoral: "rgb(240,128,128)",
843 lightcyan: "rgb(224,255,255)",
844 lightgoldenrodyellow:"rgb(250,250,210)",
845 lightgray: "rgb(211,211,211)",
846 lightgreen: "rgb(144,238,144)",
847 lightgrey: "rgb(211,211,211)",
848 lightpink: "rgb(255,182,193)",
849 lightsalmon: "rgb(255,160,122)",
850 lightseagree: "rgb(32,178,170)",
851 lightskyblue: "rgb(135,206,250)",
852 lightslategray:"rgb(119,136,153)",
853 lightslategrey:"rgb(119,136,153)",
854 lightsteelblue:"rgb(176,196,222)",
855 lightyellow: "rgb(255,255,224)",
856 lime: "rgb(0,255,0)",
857 limegreen: "rgb(50,205,50)",
858 linen: "rgb(250,240,230)",
859 magenta: "rgb(255,0,255)",
860 maroon: "rgb(128,0,0)",
861 mediumaquamarine:"rgb(102,205,170)",
862 mediumblue: "rgb(0,0,205)",
863 mediumorchid: "rgb(186,85,211)",
864 mediumpurple: "rgb(147,112,219)",
865 mediumseagreen:"rgb(60,179,113)",
866 mediumslateblue:"rgb(123,104,238)",
867 mediumspringgreen:"rgb(0,250,154)",
868 mediumturquoise:"rgb(72,209,204)",
869 mediumvioletred:"rgb(199,21,133)",
870 midnightblue: "rgb(25,25,112)",
871 mintcream: "rgb(245,255,250)",
872 mistyrose: "rgb(255,228,225)",
873 moccasin: "rgb(255,228,181)",
874 navajowhite: "rgb(255,222,173)",
875 navy: "rgb(0,0,128)",
876 oldlace: "rgb(253,245,230)",
877 olive: "rgb(128,128,0)",
878 olivedrab: "rgb(107,142,35)",
879 orange: "rgb(255,165,0)",
880 orangered: "rgb(255,69,0)",
881 orchid: "rgb(218,112,214)",
882 palegoldenrod: "rgb(238,232,170)",
883 palegreen: "rgb(152,251,152)",
884 paleturquoise: "rgb(175,238,238)",
885 palevioletred: "rgb(219,112,147)",
886 papayawhip: "rgb(255,239,213)",
887 peachpuff: "rgb(255,218,185)",
888 peru: "rgb(205,133,63)",
889 pink: "rgb(255,192,203)",
890 plum: "rgb(221,160,221)",
891 powderblue: "rgb(176,224,230)",
892 purple: "rgb(128,0,128)",
894 rosybrown: "rgb(188,143,143)",
895 royalblue: "rgb(65,105,225)",
896 saddlebrown: "rgb(139,69,19)",
897 salmon: "rgb(250,128,114)",
898 sandybrown: "rgb(244,164,96)",
899 seagreen: "rgb(46,139,87)",
900 seashell: "rgb(255,245,238)",
901 sienna: "rgb(160,82,45)",
902 silver: "rgb(192,192,192)",
903 skyblue: "rgb(135,206,235)",
904 slateblue: "rgb(106,90,205)",
905 slategray: "rgb(112,128,144)",
906 slategrey: "rgb(112,128,144)",
907 snow: "rgb(255,250,250)",
908 springgreen: "rgb(0,255,127)",
909 steelblue: "rgb(70,130,180)",
910 tan: "rgb(210,180,140)",
911 teal: "rgb(0,128,128)",
912 thistle: "rgb(216,191,216)",
913 tomato: "rgb(255,99,71)",
914 turquoise: "rgb(64,224,208)",
915 violet: "rgb(238,130,238)",
916 wheat: "rgb(245,222,179)",
917 white: "rgb(255,255,255)",
918 whitesmoke: "rgb(245,245,245)",
919 yellow: "rgb(255,255,0)",
920 yellowgreen: "rgb(154,205,50)"
922 }).apply(SVGColor.prototype);
925 /*float*/ this.x = 0;
926 // raises DOMException on setting
927 /*float*/ this.y = 0;
928 // raises DOMException on setting
929 /*float*/ this.width = 0;
930 // raises DOMException on setting
931 /*float*/ this.height = 0;
932 // raises DOMException on setting
936 function SVGAnimatedRect() {
937 /*readonly SVGRect*/ this.animVal = this.baseVal = new SVGRect();
943 /*unsigned short*/ SVG_UNIT_TYPE_UNKNOWN : 0,
944 /*unsigned short*/ SVG_UNIT_TYPE_USERSPACEONUSE : 1,
945 /*unsigned short*/ SVG_UNIT_TYPE_OBJECTBOUNDINGBOX : 2
947 function SVGStylable() {
948 /*readonly attribute SVGAnimatedString*/ this.className = new SVGAnimatedString();
949 /*readonly attribute css::CSSStyleDeclaration*/ this.style = new CSSStyleDeclaration();
950 this._attributeStyle = new CSSStyleDeclaration(); //プレゼンテーション属性の値を格納する
951 //styleのcssTextプロパティを解析するリスナーを登録しておく
953 /*getPresentationAttributeメソッド
954 *プレゼンテーション属性の値をCSSValueとして得る。これはCSSのスタイルの設定値を定めるときや、内部の動的処理に役立つ
956 /*css::CSSValue*/ SVGElement.prototype.getPresentationAttribute = function( /*DOMString*/ name ){
957 var s = this._attributeStyle.getPropertyCSSValue(name);
965 /*SVGURIReferenceオブジェクトはURI参照を用いる要素に適用される
966 *SIEでは、もっぱらXLink言語の処理を行う
968 function SVGURIReference() {
969 /*readonly SVGAnimatedString*/ this.href = new SVGAnimatedString();
970 this._instance = null; //埋め込みの場合に、読み込んだDOMツリーを結び付けておくプロパティ
972 this.addEventListener("DOMAttrModified", function(evt){
973 if ((evt.relatedNode.namespaceURI === "http://www.w3.org/1999/xlink") && (evt.attrName === "xlink:href")) {
974 evt.target.href.baseVal = evt.newValue;
975 /*_svgload_limitedを+1とすることで、
976 *SVGLoadイベントは発火されなくなる。1を引く必要がある
978 evt.target.ownerDocument.documentElement._svgload_limited++;
982 this.addEventListener("DOMNodeInserted", function(evt){
983 var tar = evt.target;
984 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
987 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
988 var tar = evt.target,
990 href = tar.href.baseVal,
991 show, egbase, ep, b, lh, uri, xmlhttp, ui, id, doc, ele, ev;
992 /*xlink:href属性とxml:base属性を手がかりに、
993 *ハイパーリンクのURIを決定する処理を行う
995 if (href !== "") { //xlink:href属性が指定されたとき
996 egbase = tar.xmlbase;
1005 if (!b) { //xml:baseの指定がなければ
1006 if (href.indexOf("#") !== 0) { //href属性において#が一番につかない場合
1008 base = lh.replace(/\/[^\/]+?$/, "/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
1010 base = location.href;
1016 if (href.indexOf(":") !== -1) { //絶対URIの場合
1020 show = tar.getAttributeNS("http://www.w3.org/1999/xlink", "show") || "embed";
1021 if (href.indexOf(".") === 0) { //相対URIの場合
1024 if (show === "replace") {
1025 tar._tar.setAttribute("href", uri);
1026 } else if (show === "new") {
1027 tar._tar.setAttribute("target", "_blank");
1028 tar._tar.setAttribute("href", uri);
1029 } else if (show === "embed") {
1030 xmlhttp = NAIBU.xmlhttp;
1031 ui = uri.indexOf("#");
1033 id = uri.slice(ui+1);
1034 uri = uri.replace(/#.+$/, "");
1038 if (href.indexOf("#") === 0) { //URIが#で始まるのであれば
1039 doc = tar.ownerDocument;
1040 ele = doc.getElementById(id);
1041 tar._instance = ele;
1042 ev = doc.createEvent("SVGEvents");
1043 ev.initEvent("S_Load", false, false);
1044 tar.dispatchEvent(ev);
1045 tar = xmlhttp = void 0;
1046 } else if (uri.indexOf("data:") > -1) {
1048 tar = xmlhttp = void 0;
1049 } else if ((uri.indexOf("http:") > -1) || (uri.indexOf(".") === 0)){
1050 if ((tar.localName === "image") && (uri.indexOf(".svg") === -1)) {
1053 /*ここの_svgload_limitedは、リンクを読み込んだ後でSVGLoadイベントを実行させるという遅延処理で必要*/
1054 tar.ownerDocument.documentElement._svgload_limited++;
1055 xmlhttp.open("GET", uri, false);
1056 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1057 xmlhttp.onreadystatechange = function() {
1058 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
1059 var type = xmlhttp.getResponseHeader('Content-Type') || "text",
1061 if ((type.indexOf("text") > -1) || (type.indexOf("xml") > -1) || (type.indexOf("script") > -1)) { //ファイルがtext形式である場合
1062 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
1063 *ここでは、responseTextを用いる
1065 /*script要素とstyle要素は、
1066 *_textプロパティに読み込んだテキストを格納しておく
1067 *それら以外は、_instanceプロパティにDOMツリーを格納しておく
1069 if (tar.localName !== "script" && tar.localName !== "style") {
1070 doc = new ActiveXObject("MSXML2.DomDocument");
1071 str = xmlhttp.responseText.replace(/!DOCTYPE/,"!--").replace(/(dtd">|\]>)/,"-->");
1072 NAIBU.doc.async = false;
1073 NAIBU.doc.validateOnParse = false;
1074 NAIBU.doc.resolveExternals = false;
1075 NAIBU.doc.preserveWhiteSpace = false;
1077 ele = doc.documentElement;
1078 tar._instance = tar.ownerDocument.importNode(ele, true);
1080 tar._instance = tar._instance.ownerDocument.getElementById(id);
1083 tar._text = xmlhttp.responseText;
1085 } else if (!!tar._tar) {
1088 /*S_LoadイベントとはSIE独自のイベント。
1089 *XLink言語によって、リンク先のコンテンツが読み込まれた時点で発火する
1091 ev = tar.ownerDocument.createEvent("SVGEvents");
1092 ev.initEvent("S_Load", false, false);
1093 tar.dispatchEvent(ev);
1094 tar.ownerDocument.documentElement._svgload_limited--;
1095 /*すべてのリンクが読み込みを終了した場合、SVGLoadイベントを発火*/
1096 if (tar.ownerDocument.documentElement._svgload_limited < 0) {
1097 ev = tar.ownerDocument.createEvent("SVGEvents");
1098 ev.initEvent("SVGLoad", false, false);
1099 tar.ownerDocument.documentElement.dispatchEvent(ev);
1101 tar = type = doc = str = ev = void 0;
1102 /*IEのメモリリーク対策として、空関数を入力*/
1103 xmlhttp.onreadystatechange = NAIBU.emptyFunction;
1111 tar.ownerDocument.documentElement._svgload_limited--;
1113 evt = base = href = egbase = ep = b = lh = uri = ui = id = doc = ele = ev = show= void 0;
1119 function SVGCSSRule() {
1120 CSSRule.apply(this, arguments);
1121 // Additional CSS RuleType to support ICC color specifications
1122 /*const unsigned short*/ this.COLOR_PROFILE_RULE = 7;
1125 SVGCSSRule.constructor = CSSRule;
1126 SVGCSSRule.prototype = new CSSRule(); //ノードのプロトタイプチェーンを作って、継承
1131 function SVGDocument(){
1132 Document.apply(this);
1133 DocumentStyle.apply(this);
1134 /*readonly DOMString*/ this.title = "";
1135 /*readonly DOMString*/ this.referrer = document.referrer;
1136 /*readonly DOMString*/ this.domain = document.domain;
1137 /*readonly DOMString*/ this.URL = document.location;
1138 /*readonly SVGSVGElement*/ this.rootElement;
1141 SVGDocument.constructor = Document;
1142 SVGDocument.prototype = new Document(); //ノードのプロトタイプチェーンを作って、継承
1147 function SVGSVGElement(_doc) {
1148 SVGElement.apply(this, arguments);
1149 this._tar = _doc.createElement("v:group");
1151 /*_svgload_limitedはSVGLoadイベントを発火させる判定基準。
1152 * Xlink言語が使われていない限り0であり、SVGLoadイベントが発火される*/
1153 this._svgload_limited = 0;
1157 SVGExternalResourcesRequired,
1162 events::EventTarget,
1163 events::DocumentEvent,
1165 css::DocumentCSS {*/
1166 /*以下のx,y,width,heightプロパティは
1167 *それぞれ、svg要素の同名属性に対応。たとえば、xならば、x属性に対応している
1168 *1000というのは、W3Cで触れていないため、独自の初期値を採用
1170 var slen = SVGAnimatedLength;
1171 /*readonly SVGAnimatedLength*/ this.x = new slen();
1172 /*readonly SVGAnimatedLength*/ this.y = new slen();
1173 /*readonly SVGAnimatedLength*/ this.width = new slen();
1174 /*readonly SVGAnimatedLength*/ this.height = new slen();
1176 /*DOMString*/ this.contentScriptType = "application/ecmascript"; //古い仕様では、text/ecmascript
1177 /*DOMString*/ this.contentStyleType = "text/css";
1178 /*readonly SVGRect*/ this.viewport = this.createSVGRect();
1179 /*useCurrentViewプロパティ
1180 * view要素やハイパーリンクなどで呼び出された場合、true。それ以外の通常表示はfalse。
1182 /*boolean*/ this.useCurrentView = false;
1184 * ズームやパンがされていない初期表示のviewBoxプロパティなどを示す。通常はDOM属性と連動
1186 /*readonly SVGViewSpec*/ this.currentView = new SVGViewSpec(this);
1187 /*もし、画像をズームやパンしたとき、どのような倍率になるかを
1188 *以下のプロパティを使って次の行列で示すことができる
1189 *2x3 行列 [a b c d e f] = [currentScale 0 0 currentScale currentTranslate.x currentTranslate.y]
1191 /*float*/ this.currentScale = 1;
1192 /*readonly SVGPoint*/ this.currentTranslate = this.createSVGPoint();
1193 /*以下は、SVGFitToViewBoxのインターフェースを用いる
1194 *もし、ズームやパンがあれば、真っ先にこれらのプロパティを別のオブジェクトに変更すること
1196 /*readonly SVGAnimatedRect*/ this.viewBox = this.currentView.viewBox;
1197 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = this.currentView.preserveAspectRatio;
1198 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
1201 /*int*/ this._currentTime = 0;
1202 /*DOMAttrModifiedイベントを利用して、
1203 *随時、属性の値をDOMプロパティに変換しておくリスナー登録
1205 this.addEventListener("DOMAttrModified", function(evt){
1206 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1209 var tar = evt.target,
1210 name = evt.attrName,
1211 tv, ovb, par, tp, sa, mos;
1212 if (name === "viewBox") {
1213 tar._cacheScreenCTM = null;
1214 tv = tar.viewBox.baseVal;
1215 ovb = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
1216 tv.x = parseFloat(ovb[0]);
1217 tv.y = parseFloat(ovb[1]);
1218 tv.width = parseFloat(ovb[2]);
1219 tv.height = parseFloat(ovb[3]);
1220 tar.viewBox.baseVal._isUsed = 1;
1221 } else if (name === "preserveAspectRatio") {
1222 tar._cacheScreenCTM = null;
1224 tp = tar.preserveAspectRatio.baseVal;
1226 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_UNKNOWN;
1227 if (!!par.match(/x(Min|Mid|Max)Y(Min|Mid|Max)(?:\s+(meet|slice))?/)) {
1228 switch (RegExp.$1) {
1239 switch (RegExp.$2) {
1249 if (RegExp.$3 === "slice") {
1250 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE;
1252 mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
1256 tp.meetOrSlice = mos;
1257 } else if (name === "width") {
1259 tar.viewport.width = tar.width.baseVal.value;
1260 } else if (name === "height") {
1261 tar.viewport.height = tar.height.baseVal.value;
1263 evt = name = tv = ovb = par = tp = sa = mos = void 0;
1265 this.addEventListener("SVGLoad", function(evt){
1266 /*以下のDOMAttrModifiedは浮上フェーズのときに、再描画をするように
1267 *処理を書いたもの。属性が書き換わるたびに、再描画される
1269 evt.target.addEventListener("DOMAttrModified", function(evt){
1272 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1274 if (tar.parentNode) {
1275 evtt = tar.ownerDocument.createEvent("MutationEvents");
1276 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1278 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
1279 tce = tar._capter; //tceは登録しておいたリスナーのリスト
1280 for (var j=0,tcli=tce.length;j<tcli;++j){
1282 tce[j].handleEvent(evtt);
1285 if (((tar.localName === "g") || (tar.localName === "a")) && (tar.namespaceURI === "http://www.w3.org/2000/svg")) {
1286 tar._cacheMatrix = void 0; //キャッシュを消去
1287 if (tar.firstChild) {
1288 slist = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
1289 for (var i=0,sli=slist.length;i<sli;++i) {
1291 tar._cacheMatrix = void 0;
1292 evtt = tar.ownerDocument.createEvent("MutationEvents");
1293 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
1295 evtt.eventPhase = /*Event.AT_TARGET*/ 2;
1296 tce = tar._capter; //tceは登録しておいたリスナーのリスト
1297 for (var j=0,tcli=tce.length;j<tcli;++j){
1299 tce[j].handleEvent(evtt);
1307 evtt = tar = evt = tce = slist = void 0;
1313 SVGSVGElement.constructor = SVGElement;
1314 SVGSVGElement.prototype = new SVGElement();
1315 /*void*/ SVGSVGElement.prototype.forceRedraw = function() {
1317 /*float*/ SVGSVGElement.prototype.getCurrentTime = function(){
1318 return (this._currentTime);
1320 /*void*/ SVGSVGElement.prototype.setCurrentTime = function(/*float*/ seconds ){
1321 this._currentTime = seconds;
1323 /*SVGNumber*/ SVGSVGElement.prototype.createSVGNumber = function(){
1324 var s = new SVGNumber();
1328 /*SVGAngle*/ SVGSVGElement.prototype.createSVGAngle = function(){
1329 var s = new SVGAngle();
1334 /*SVGLength*/ SVGSVGElement.prototype.createSVGLength = function(){
1335 var s = new SVGLength();
1336 s.unitType = /*SVG_LENGTHTYPE_NUMBER*/ 1;
1339 /*SVGPoint*/ SVGSVGElement.prototype.createSVGPoint = function(){
1340 return new SVGPoint();
1342 /*SVGMatrix*/ SVGSVGElement.prototype.createSVGMatrix = function(){
1344 return new SVGMatrix();
1346 /*SVGRect*/ SVGSVGElement.prototype.createSVGRect = function(){
1347 return new SVGRect();
1349 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransform = function(){
1350 var s = this.createSVGTransformFromMatrix(this.createSVGMatrix());
1353 /*SVGTransform*/ SVGSVGElement.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ){
1354 var s = new SVGTransform();
1355 s.setMatrix(matrix);
1359 *SVGElement(SVGLocatable)で指定しておいたメソッドであるが、ここで、算出方法が違うため、再定義をする
1361 /*SVGMatrix*/ SVGSVGElement.prototype.getScreenCTM = function(){
1362 if (!!this._cacheScreenCTM) { //キャッシュがあれば
1363 return (this._cacheScreenCTM);
1365 var vw = this.viewport.width,
1366 vh = this.viewport.height,
1367 vB, par, m, vbx, vby, vbw, vbh, rw, rh, xr, yr, tx, ty, ttps;
1368 if (!this.useCurrentView) {
1369 vB = this.viewBox.baseVal;
1370 par = this.preserveAspectRatio.baseVal;
1372 vB = this.currentView.viewBox.baseVal;
1373 par = this.currentView.preserveAspectRatio.baseVal;
1375 if (!!!vB._isUsed) { //viewBox属性が指定されていなければ
1376 this._tx = this._ty = 0;
1377 m = this.createSVGMatrix();
1378 this._cacheScreenCTM = m; //キャッシュを作っておく
1391 if (par.align === 1) { //none
1397 var ax = (par.align + 1) % 3 + 1;
1398 var ay = Math.round(par.align / 3);
1399 switch (par.meetOrSlice) {
1401 xr = yr = Math.min(rw, rh);
1404 xr = yr = Math.max(rw, rh);
1413 tx += (vw - vbw * xr) / 2;
1416 tx += vw - vbw * xr;
1423 ty += (vh - vbh * yr) / 2;
1426 ty += vh - vbh * yr;
1431 //text要素の位置調整に使うため、ここで、viewの移動量を記録しておく
1434 ttps = this._tar.style;
1435 ttps.marginLeft = tx+ "px";
1436 ttps.marginTop = ty+ "px";
1437 m = this.createSVGMatrix();
1440 this._cacheScreenCTM = m; //キャッシュを作っておく
1441 vw = vh = vB = par = vbx = vby = vbw = vbh = rw = rh = xr = yr = tx = ty = ttps = void 0;
1445 /*interface SVGZoomAndPan*/
1446 // Zoom and Pan Types
1448 /*const unsigned short*/ SVG_ZOOMANDPAN_UNKNOWN : 0,
1449 /*const unsigned short*/ SVG_ZOOMANDPAN_DISABLE : 1,
1450 /*const unsigned short*/ SVG_ZOOMANDPAN_MAGNIFY : 2
1453 function SVGFitToViewBox() {
1454 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
1455 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
1458 function SVGViewSpec(ele) {
1459 SVGFitToViewBox.apply(this, arguments);
1460 /*readonly SVGTransformList*/ this.transform = new SVGTransformList();
1461 /*readonly SVGElement*/ this.viewTarget = ele;
1462 /*readonly DOMString*/ this.viewBoxString = this.preserveAspectRatioString = this.transformString = this.viewTargetString = "";
1465 SVGViewSpec.constructor = SVGFitToViewBox;
1466 SVGViewSpec.prototype = new SVGFitToViewBox();
1468 function SVGGElement(_doc) {
1469 SVGElement.apply(this);
1470 this._tar = _doc.createElement("v:group");
1472 /*以下の処理は、この子要素ノードがDOMツリーに追加されて初めて、
1473 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
1475 this.addEventListener("DOMNodeInserted", function(evt){
1476 var tar = evt.target;
1477 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1480 var tnext = tar.nextSibling,
1481 tpart = tar.parentNode._tar,
1483 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
1484 tpart.insertBefore(tar._tar, tnext._tar);
1485 } else if (tnext && !tnext._tar && tpart) {
1486 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
1487 *use要素や実体参照などは_tarプロパティがないことに注意
1490 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
1491 tpart.insertBefore(tar._tar, tnext._tar);
1494 tnext = tnext.nextSibling;
1497 tpart.appendChild(tar._tar);
1499 } else if (!tnext && tpart) {
1500 tpart.appendChild(tar._tar);
1502 tnext = tpart = isLast = evt = tar = void 0;
1506 SVGGElement.constructor = SVGElement;
1507 SVGGElement.prototype = new SVGElement();
1509 function SVGDefsElement() {
1510 SVGElement.apply(this, arguments);
1511 this.style.setProperty("display", "none");
1514 SVGDefsElement.constructor = SVGElement;
1515 SVGDefsElement.prototype = new SVGElement();
1517 function SVGDescElement() {
1518 SVGElement.apply(this, arguments);
1521 SVGDescElement.constructor = SVGElement;
1522 SVGDescElement.prototype = new SVGElement();
1524 function SVGTitleElement() {
1525 SVGElement.apply(this, arguments);
1526 this.addEventListener("DOMCharacterDataModified", function(evt){
1527 evt.target.ownerDocument.title = evt.target.firstChild.nodeValue;
1531 SVGTitleElement.constructor = SVGElement;
1532 SVGTitleElement.prototype = new SVGElement();
1534 function SVGSymbolElement() {
1535 SVGElement.apply(this, arguments);
1536 SVGURIReference.apply(this);
1539 SVGDefsElement.constructor = SVGElement;
1540 SVGDefsElement.prototype = new SVGElement();
1542 function SVGUseElement() {
1543 SVGGElement.apply(this, arguments);
1544 var slen = SVGAnimatedLength;
1545 /*readonly SVGAnimatedLength*/ this.x = new slen(); //use要素のx属性に対応(以下、同様)
1546 /*readonly SVGAnimatedLength*/ this.y = new slen();
1547 /*readonly SVGAnimatedLength*/ this.width = new slen();
1548 /*readonly SVGAnimatedLength*/ this.height = new slen();
1550 /*readonly SVGElementInstance*/ this.instanceRoot = new SVGElementInstance(); //参照先インスタンスのルート
1551 /*readonly SVGElementInstance*/ this.animatedInstanceRoot = new SVGElementInstance();//アニメの最中のインスタンス。静止中は通常
1552 this.addEventListener("DOMNodeInserted", function(evt){
1553 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1556 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
1558 this.addEventListener("S_Load", function(evt){
1559 var tar = evt.target,
1560 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
1561 fontSize = parseFloat(style.getPropertyValue("font-size")),
1562 tgtb = tar.transform.baseVal,
1563 trans = tar.ownerDocument.documentElement.createSVGTransform();
1564 tar.x.baseVal._emToUnit(fontSize);
1565 tar.y.baseVal._emToUnit(fontSize);
1566 tar.width.baseVal._emToUnit(fontSize);
1567 tar.height.baseVal._emToUnit(fontSize);
1568 tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tar._instance, true);
1569 trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value);
1570 tgtb.appendItem(trans);
1571 tar.appendChild(tar.instanceRoot);
1572 evt = trans = tar = evtt = tgtb = style = fontSize = void 0;
1574 SVGURIReference.apply(this);
1577 SVGUseElement.constructor = SVGElement;
1578 SVGUseElement.prototype = new SVGElement();
1580 function SVGElementInstance() {
1584 Node.apply(this, arguments);
1585 /*readonly SVGElement*/ this.correspondingElement; //use要素で使われる参照先の要素
1586 /*readonly SVGUseElement*/ this.correspondingUseElement; //参照先の要素にuse要素が含まれているとき、ここにuse要素を収納
1587 /*readonly SVGElementInstance*/ this.parentNode;
1588 /*readonly SVGElementInstanceList*/ this.childNodes;
1589 /*readonly SVGElementInstance*/ this.firstChild;
1590 /*readonly SVGElementInstance*/ this.lastChild;
1591 /*readonly SVGElementInstance*/ this.previousSibling;
1592 /*readonly SVGElementInstance*/ this.nextSibling;
1595 SVGElementInstance.prototype = new Node();
1596 /*SVGElementInstanceList
1598 function SVGElementInstanceList() {
1599 /*readonly unsigned long*/ this.length = 0;
1602 /*SVGElementInstance*/ SVGElementInstanceList.prototype.item = function(/*unsigned long*/ index ) {
1603 return (this[index]);
1605 function SVGImageElement(_doc) {
1606 SVGElement.apply(this, arguments);
1607 this._tar = _doc.createElement("v:image");
1608 //以下は、与えられた属性の値に対応する
1609 var slen = SVGAnimatedLength;
1610 /*readonly SVGAnimatedLength*/ this.x = new slen();
1611 /*readonly SVGAnimatedLength*/ this.y = new slen();
1612 /*readonly SVGAnimatedLength*/ this.width = new slen();
1613 /*readonly SVGAnimatedLength*/ this.height = new slen();
1614 _doc = slen = void 0;
1615 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
1616 this.addEventListener("DOMNodeInserted", function(evt){
1617 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
1620 var tar = evt.target;
1621 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
1622 if (tar.nextSibling) {
1623 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
1624 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
1626 } else if (!!tar.parentNode._tar){
1627 tar.parentNode._tar.appendChild(tar._tar);
1629 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
1630 var tar = evt.target,
1631 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
1632 fontSize = parseFloat(style.getPropertyValue("font-size")),
1633 ts = tar._tar.style,
1634 ctm = tar.getScreenCTM(),
1635 po = tar.ownerDocument.documentElement.createSVGPoint(),
1636 fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")),
1638 tar.x.baseVal._emToUnit(fontSize);
1639 tar.y.baseVal._emToUnit(fontSize);
1640 tar.width.baseVal._emToUnit(fontSize);
1641 tar.height.baseVal._emToUnit(fontSize);
1642 ts.position = "absolute";
1643 po.x = tar.x.baseVal.value;
1644 po.y = tar.y.baseVal.value;
1645 po = po.matrixTransform(ctm);
1646 ts.left = po.x + "px";
1647 ts.top = po.y + "px";
1648 ts.width = tar.width.baseVal.value * ctm.a + "px";
1649 ts.height = tar.height.baseVal.value * ctm.d + "px";
1650 if (fillOpacity !== 1) {
1651 ts.filter = "progid:DXImageTransform.Microsoft.Alpha";
1652 ttfia = tar._tar.filters.item('DXImageTransform.Microsoft.Alpha');
1654 ttfia.Opacity = fillOpacity * 100;
1657 evt = tar = style = fontSize = ts = ctm = po = fillOpacity = void 0;
1661 SVGURIReference.apply(this);
1664 SVGImageElement.constructor = SVGElement;
1665 SVGImageElement.prototype = new SVGElement();
1667 function SVGSwitchElement() {
1668 SVGElement.apply(this, arguments);
1671 SVGSwitchElement.constructor = SVGElement;
1672 SVGSwitchElement.prototype = new SVGElement();
1674 //bookmarkletから呼び出されたらtrue
1676 function GetSVGDocument(ele) {
1682 if ((NAIBU._that.xmlhttp.readyState === 4) && (NAIBU._that.xmlhttp.status === 200)) {
1686 GetSVGDocument.prototype = {
1688 *object(embed)要素で指定されたSVG文書を読み込んで、SVGを処理して表示させるメソッド
1690 _init : function() {
1691 /*objeiはobject要素かembed要素*/
1692 var xmlhttp = NAIBU.xmlhttp,
1695 if (this._tar.nodeName === "OBJECT") {
1700 xmlhttp.open("GET", objei.getAttribute(data), true);
1701 objei.style.display = "none";
1702 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
1703 this.xmlhttp = xmlhttp;
1704 /*クロージャを利用しないことで、軽量化を計る*/
1706 xmlhttp.onreadystatechange = _ca_;
1708 xmlhttp = objei = data = void 0;
1712 /*responseXMLを使うと、時々、空のデータを返すことがあるため(原因はcontent-typeが"text/xml"など特定のものでないと受け付けないため)、
1713 *ここでは、responseTextを用いる
1715 var dsd = new Date();
1716 var ifr = this._tar.previousSibling,
1717 ifcw = ifr.contentWindow,
1720 ifr.contentWindow.screen.updateInterval = 999;
1721 _doc = ifr.contentWindow.document;
1723 _doc.close(); // これがないと document.body は null になる
1724 } else { //インラインSVGの場合
1727 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
1728 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
1729 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
1730 var st = _doc.createStyleSheet(),
1731 vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
1732 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
1733 + "dn\\:defs{display:none}"
1734 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
1735 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
1736 st = vmlUrl = void 0;
1738 DOMImplementation._doc_ = _doc; //_doc_プロパティはcreateDocumentメソッドで使う
1739 var str = this.xmlhttp.responseText,
1741 s = DOMImplementation.createDocument("http://www.w3.org/2000/svg", "svg"),
1742 tar = s.documentElement,
1743 tview = tar.viewport,
1744 objw, objh, fi, n, attr, att, w, h,
1746 sp = _doc.createElement("div"),
1747 dcp = _doc.createElement("v:group"),
1748 backr = _doc.createElement("v:rect"),
1749 style, fontSize, sw, sh, trstyle, tpstyle, backrs, viewWidth, viewHeight, backdown, backright,
1751 _parseFloat = parseFloat,
1752 ndoc = NAIBU.doc || this.xmlhttp.responseXML,
1753 oba = _doc.createElement("div"); //obaはradialGradient要素で使う
1754 if (!ndoc) { //何らかの原因で読み込み失敗した場合、実行させないようにする
1755 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
1758 s._iframe = ifr; //_iframeプロパティはSVGAElementでリンク置換のときに扱う
1759 oba.setAttribute("id","_NAIBU_outline");
1760 _doc.body.appendChild(oba);
1761 sp.style.margin = "-1px,0px,0px,-1px"
1763 _doc.body.style.backgroundColor = objei.parentNode.currentStyle.backgroundColor;
1766 /*下記のプロパティについては、Microsoftのサイトを参照
1767 *ResolveExternals Property [Second-level DOM]
1768 * http://msdn.microsoft.com/en-us/library/ms761375%28VS.85%29.aspx
1769 *ValidateOnParse Property [Second-level DOM]
1770 * http://msdn.microsoft.com/en-us/library/ms760286%28VS.85%29.asp
1772 ndoc.validateOnParse = false;
1773 ndoc.resolveExternals = false;
1774 ndoc.preserveWhiteSpace = true;
1775 ndoc.loadXML(str.replace(/^[\s\S]*?<svg/, "<svg")); //XML宣言のUTF-8は問題が起きるので削除
1776 /*IE6-8のみで使えるupdateIntervalは、
1777 *描画間隔の調整が可能。デフォルトは0。
1778 *スクロール時にバグが起きるので、0に戻してやる必要がある。
1780 screen.updateInterval = 999;
1781 if (/&[^;]+;/.test(str)) {
1783 *代替の処理を用いて、実体参照を処理するもの
1786 var enti = (ndoc.doctype)? ndoc.doctype.entities: { length:0 };
1787 for (var i=0; i<enti.length; i++) {
1788 var map = enti.item(i);
1789 var regex = new RegExp("&"+map.nodeName+";", "g");
1790 tmp = tmp.replace(regex, map.firstChild.xml);
1797 tview.width = objei.clientWidth;
1798 tview.height = objei.clientHeight;
1799 if (tview.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
1800 tview.height = screen.availHeight;
1802 if (tar.viewport.height < 24) { //IEの標準モードではclientHeightプロパティの値が小さくなることがある
1803 tar.viewport.height = screen.width;
1805 objw = objei.getAttribute("width");
1806 objh = objei.getAttribute("height");
1808 tar.setAttributeNS(null, "width", objw);
1811 tar.setAttributeNS(null, "height", objh);
1813 fi = ndoc.documentElement.firstChild;
1814 attr = ndoc.documentElement.attributes;
1815 /*ルート要素のNamedNodeMapを検索する*/
1816 for (var i=0,atli=attr.length;i<atli;++i) {
1817 att = s.importNode(attr[i], false);
1818 tar.setAttributeNodeNS(att);
1820 str = attr = void 0;
1821 dcp.style.width = tview.width+ "px";
1822 dcp.style.height = tview.height+ "px";
1823 dcp.coordsize = tview.width+ " " +tview.height;
1824 sp.appendChild(dcp);
1826 _doc.body.appendChild(sp);
1828 this._tar.parentNode.insertBefore(sp, this._tar);
1830 dcp.appendChild(sdt);
1831 while (fi) { //子ノードを検索して、子供がいれば、importNodeメソッドを再帰的に実行する
1832 n = s.importNode(fi, true);
1834 fi = fi.nextSibling;
1837 /*dom/event.jsのaddEventListenerメソッドなどで、iframe要素のwindowオブジェクトを利用する必要があるため、
1838 *ドキュメントにそのオブジェクトを結び付けておく
1841 /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を
1844 style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
1845 fontSize = _parseFloat(style.getPropertyValue("font-size"));
1846 tar.x.baseVal._emToUnit(fontSize);
1847 tar.y.baseVal._emToUnit(fontSize);
1848 tar.width.baseVal._emToUnit(fontSize);
1849 tar.height.baseVal._emToUnit(fontSize);
1850 sw = tar.width.baseVal.value;
1851 sh = tar.height.baseVal.value;
1852 backr.style.position = "absolute";
1855 backr.style.width = w+ "px";
1856 backr.style.height = h+ "px";
1857 backr.style.zIndex = -1;
1858 backr.stroked = "false";
1859 backr.filled = "false";
1860 tar._tar.appendChild(backr);
1861 trstyle = tar._tar.style;
1862 tpstyle = objei.style;
1863 trstyle.visibility = "visible";
1864 trstyle.position = "absolute";
1866 trstyle.overflow = "hidden";
1868 viewWidth = w > sw ? sw : w;
1869 viewHeight = h > sh ? sh : h;
1870 backrs = backr.currentStyle;
1871 bfl = _parseFloat(backrs.left);
1872 bft = _parseFloat(backrs.top);
1873 bl = -tar._tx; //blやbtは、ずれを調整するのに使う
1875 if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため)
1877 dcp.style.left = -bl+ "px";
1879 if (bft !== 0 && !isNaN(bfl)) {
1881 dcp.style.top = -bt+ "px";
1883 backright = bl + viewWidth + 1;
1884 backdown = bt + viewHeight + 1;
1885 trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)";
1887 if ("_svgload_limited" in s.documentElement) {
1888 /*_svgload_limitedプロパティはXlink言語が使われていない限り、0である。
1889 *xlink:href属性が指定されるたびに+1となる。
1890 *0以外は、SVGLoadイベントが発火されない仕組みとなっている
1893 * Xlinkのリンク先のソースを読み込むまで、SVGLoadイベントを発火させないため
1895 s.documentElement._svgload_limited--;
1896 if (s.documentElement._svgload_limited < 0) {
1897 var evt = s.createEvent("SVGEvents");
1898 evt.initEvent("SVGLoad", false, false);
1899 s.documentElement.dispatchEvent(evt);
1903 text = s.documentElement._tar.getElementsByTagName("div");
1904 for (var i=0, texti;text[i];++i) {
1906 if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば
1907 var tis = texti.style;
1908 tis.left = _parseFloat(tis.left) + bl + "px";
1909 tis.top = _parseFloat(tis.top) + bt + "px";
1913 //ビューポートの位置をスクロールで調整 (なお、_txプロパティはSVGSVGElementのSIEコードを参照)
1914 ifcw && ifcw.scroll(-s.documentElement._tx, -s.documentElement._ty);
1915 s._isLoaded = 1; //_isLoadedプロパティはevents::dispatchEventメソッドで使う
1916 s.defaultView._cache = s.defaultView._cache_ele = null;
1917 oba = _doc = evt = ndoc = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = sw = sh = style = fontSize = void 0;
1918 trstyle = tpstyle = backrs = text = texti = i = bfl = bft = bl = bt = text = _parseFloat = w = h = viewWidth = viewHeight = backdown = backright = void 0;
1919 /*IEのメモリリーク対策として、空関数を入力*/
1920 this.xmlhttp.onreadystatechange = NAIBU.emptyFunction;
1921 alert(+(new Date()) - dsd);
1923 ifcw && (ifr.contentWindow.screen.updateInterval = 0);
1924 ifr = ifcw = s = void 0;
1928 if (s.implementation._buffer_) {
1929 screen.updateInterval = 0;
1930 /*以下はバッファリングにためておいた要素とイベントを、後から実行する*/
1931 NAIBU._buff_num = 0;
1932 NAIBU._buff = setInterval(function(){
1933 var n = NAIBU._buff_num,
1934 dbuf = DOMImplementation._buffer_,
1935 dbufli = dbuf ? dbuf.length : 0, //極端な負荷がかかると、dbufはnullになる可能性あり
1938 clearInterval(NAIBU._buff);
1940 for (var i=0;i<50;++i) {
1943 s.dispatchEvent(evt);
1947 clearInterval(NAIBU._buff);
1948 DOMImplementation._buffer_ = null;
1950 dbuf = n = dbufli = void 0;
1954 NAIBU._buff_num = n;
1956 dbuf = n = dbufli = void 0;
1958 ifr = ifcw = s = void 0;
1960 ifr = ifcw = s = void 0;
1966 /*SVGDocument*/ getSVGDocument : function() {
1967 return (this._document);
1970 /*空関数(IEのメモリリーク対策)*/
1971 NAIBU.emptyFunction = function() {};
1976 function SVGStyleElement(_doc) {
1977 SVGElement.apply(this);
1978 LinkStyle.apply(this);
1979 /*LinkStyleに関しては、以下の仕様を参照のこと。なお、これはSVG DOMでは継承されていないので要注意。
1980 *CSS2 1. Document Object Model Style Sheets
1981 * 1.3. Document Extensions
1982 * Interface LinkStyle (introduced in DOM Level 2)
1983 * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-LinkStyle
1985 /*以下はそれぞれ、属性の値に対応している*/
1986 /*DOMString*/ this.xmlspace;
1987 /*DOMString*/ this.type = "text/css";
1988 /*DOMString*/ this.media;
1989 /*DOMString*/ this.title;
1990 SVGURIReference.apply(this);
1991 this.addEventListener("DOMAttrModified", function(evt){
1992 if (evt.attrName === "type") {
1993 evt.target.type = evt.newValue;
1994 } else if (evt.attrName === "title") {
1995 evt.target.title = evt.newValue;
1999 this.addEventListener("S_Load", function(evt){
2000 var tar = evt.target,
2002 styleText = tar._text,
2003 tod = tar.ownerDocument,
2004 style = _doc.createElement("style"),
2006 NAIBU._temp_doc = tod;
2007 sheet = tod.styleSheets[tod.styleSheets.length] = DOMImplementation.createCSSStyleSheet(tar.title, tar.media);
2008 sheet.ownerNode = tar;
2009 /*以下は、IEのCSSパーサを使って、スタイルシートのルールを実装していく*/
2010 _doc.documentElement.firstChild.appendChild(style);
2011 style.styleSheet.cssText = styleText;
2012 for (var i=0, rules=style.styleSheet.rules, rli=rules.length;i<rli;++i) {
2014 scri = new CSSStyleRule();
2015 scri.selectorText = ri.selectorText;
2016 scri.style.cssText = ri.style.cssText;
2017 rsc = scri.style.cssText.split(";");
2018 for (var j=0, rsli=rsc.length;j<rsli;++j) {
2019 rsi = rsc[j].split(": ");
2020 scri.style.setProperty(rsi[0], rsi[1]);
2022 sheet.cssRules[sheet.cssRules.length] = scri;
2024 tod.documentElement.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
2025 var tar = evt.target,
2026 doc = tar.ownerDocument,
2027 rules = doc.styleSheets[0] ? doc.styleSheets[0].cssRules : [],
2028 selector, ru, tcb = tar.className.baseVal || ".,.";
2029 for (var i=0, rli=rules.length;i<rli;++i) {
2030 selector = rules[i].selectorText;
2031 /*_rulesプロパティはCSSモジュールのgetCoumputedStyleメソッドで使う*/
2032 ru = tar._rules || [];
2033 if ((selector.indexOf("." +tcb) > -1) || (selector.indexOf("#" +tar.id) > -1)
2034 || (tar.nodeName === selector)) {
2035 ru[ru.length] = rules[i];
2039 tar = doc = rules = void 0;
2041 tar = evt = style = sheet = styleText = tod = i = rules = rli = void 0;
2043 this.addEventListener("DOMNodeInserted", function(evt){
2044 var tar = evt.target;
2045 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2046 if (tar.nodeName === "#cdata-section") {
2047 evt.currentTarget._text = tar.data;
2051 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
2052 var tar = evt.target;
2053 if ((evt.eventPhase === Event.AT_TARGET) && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
2054 var evtt = tar.ownerDocument.createEvent("SVGEvents");
2055 evtt.initEvent("S_Load", false, false);
2056 evt.currentTarget.dispatchEvent(evtt);
2063 SVGStyleElement.constructor = SVGElement;
2064 SVGStyleElement.prototype = new SVGElement();
2067 *2次元座標の点(x,y)を表すオブジェクト
2069 function SVGPoint() {
2072 /*float*/SVGPoint.prototype.x = SVGPoint.prototype.y = 0;
2073 SVGPoint.prototype.matrixTransform = function(/*SVGMatrix*/ matrix ) {
2074 /*整数にしているのは、VMLの設計上、小数点を扱えないときがあるため*/
2075 var s = new SVGPoint();
2076 s.x = matrix.a * this.x + matrix.c * this.y + matrix.e;
2077 s.y = matrix.b * this.x + matrix.d * this.y + matrix.f;
2081 function SVGPointList() {
2084 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2085 SVGPointList.prototype[prop] = SVGStringList.prototype[prop];
2089 *行列をあらわすオブジェクト。写像に用いる。以下のように表現できる
2094 function SVGMatrix() {
2097 SVGMatrix.prototype = {
2107 /*SVGMatrix*/ multiply : function(/*SVGMatrix*/ secondMatrix ) {
2108 var s = new SVGMatrix(), m = secondMatrix;
2109 if (!isFinite(m.a) || !isFinite(m.b) || !isFinite(m.c) || !isFinite(m.d) || !isFinite(m.e) || !isFinite(m.f)) {
2110 throw (new Error("引数の値がNumber型ではありません"));
2112 s.a = this.a * m.a + this.c * m.b;
2113 s.b = this.b * m.a + this.d * m.b;
2114 s.c = this.a * m.c + this.c * m.d;
2115 s.d = this.b * m.c + this.d * m.d;
2116 s.e = this.a * m.e + this.c * m.f + this.e;
2117 s.f = this.b * m.e + this.d * m.f + this.f;
2118 m = secondMatrix = void 0;
2124 /*SVGMatrix*/ inverse : function() {
2125 var s = new SVGMatrix(), n = this._determinant();
2131 s.e = (this.c * this.f - this.d * this.e) / n;
2132 s.f = (this.b * this.e - this.a * this.f) / n;
2135 throw (new SVGException(SVGException.SVG_MATRIX_NOT_INVERTABLE));
2138 /*SVGMatrix*/ translate : function(/*float*/ x, /*float*/ y ) {
2139 var m = new SVGMatrix();
2142 var s = this.multiply(m);
2146 /*SVGMatrix*/ scale : function(/*float*/ scaleFactor ) {
2147 var m = new SVGMatrix();
2150 var s = this.multiply(m);
2154 /*SVGMatrix*/ scaleNonUniform : function(/*float*/ scaleFactorX, /*float*/ scaleFactorY ) {
2155 var m = new SVGMatrix();
2158 var s = this.multiply(m);
2162 /*SVGMatrix*/ rotate : function(/*float*/ angle ) {
2163 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
2164 m.a = Math.cos(rad);
2165 m.b = Math.sin(rad);
2168 var s = this.multiply(m);
2172 //座標(x, y)と原点の角度の分だけ、回転する
2173 /*SVGMatrix*/ rotateFromVector : function(/*float*/ x, /*float*/ y ) {
2174 if ((x === 0) || (y === 0) || !isFinite(x) || !isFinite(y)) {
2175 throw (new SVGException(SVGException.SVG_INVALID_VALUE_ERR))
2177 var m = new SVGMatrix(), rad = Math.atan2(y, x);
2178 m.a = Math.cos(rad);
2179 m.b = Math.sin(rad);
2182 var s = this.multiply(m);
2186 /*SVGMatrix*/ flipX : function() {
2187 var m = new SVGMatrix();
2189 var s = this.multiply(m);
2193 /*SVGMatrix*/ flipY : function() {
2194 var m = new SVGMatrix();
2196 var s = this.multiply(m);
2200 /*SVGMatrix*/ skewX : function(/*float*/ angle ){
2201 var m = new SVGMatrix(), rad = angle / 180 * Math.PI; //ラジアン変換
2202 m.c = Math.tan(rad);
2203 var s = this.multiply(m);
2207 /*SVGMatrix*/ skewY : function(/*float*/ angle ){
2208 var m = new SVGMatrix(), rad = angle / 180 * Math.PI;
2209 m.b = Math.tan(rad);
2210 var s = this.multiply(m);
2215 /*float*/ _determinant : function() {
2216 return (this.a * this.d - this.b * this.c);
2220 function SVGTransform() {
2221 /*readonly SVGMatrix*/ this.matrix = new SVGMatrix();
2225 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_UNKNOWN = 0;
2226 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_MATRIX = 1;
2227 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_TRANSLATE = 2;
2228 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SCALE = 3;
2229 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_ROTATE = 4;
2230 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWX = 5;
2231 /*unsigned short*/ SVGTransform.SVG_TRANSFORM_SKEWY = 6;
2232 SVGTransform.prototype = {
2233 /*ダミーの単位行列。各メソッドで使う*/
2234 _matrix : (new SVGMatrix()),
2235 /*readonly unsigned short*/ type : SVGTransform.SVG_TRANSFORM_UNKNOWN,
2236 /*readonly float*/ angle : 0,
2237 /*void*/ setMatrix : function(/*SVGMatrix*/ matrix ) {
2238 this.type = /*SVGTransform.SVG_TRANSFORM_MATRIX*/ 1;
2239 this.matrix = this._matrix.multiply(matrix);
2241 /*void*/ setTranslate : function(/*float*/ tx, /*float*/ ty ) {
2242 this.type = /*SVGTransform.SVG_TRANSFORM_TRANSLATE*/ 2;
2243 this.matrix = this._matrix.translate(tx, ty);
2245 /*void*/ setScale : function(/*float*/ sx, /*float*/ sy ) {
2246 this.type = /*SVGTransform.SVG_TRANSFORM_SCALE*/ 3;
2247 this.matrix = this._matrix.scaleNonUniform(sx, sy);
2249 /*void*/ setRotate : function(/*float*/ angle, /*float*/ cx, /*float*/ cy ) {
2251 this.type = /*SVGTransform.SVG_TRANSFORM_ROTATE*/ 4;
2252 this.matrix = this._matrix.rotate(angle);
2253 this.matrix.e = (1-this.matrix.a)*cx - this.matrix.c*cy;
2254 this.matrix.f = -this.matrix.b*cx + (1-this.matrix.d)*cy;
2256 /*void*/ setSkewX : function(/*float*/ angle ) {
2258 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWX*/ 5;
2259 this.matrix = this._matrix.skewX(angle);
2261 /*void*/ setSkewY : function(/*float*/ angle ) {
2263 this.type = /*SVGTransform.SVG_TRANSFORM_SKEWY*/ 6;
2264 this.matrix = this._matrix.skewY(angle);
2268 function SVGTransformList() {
2271 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2272 SVGTransformList.prototype[prop] = SVGStringList.prototype[prop];
2274 /*SVGTransform*/ SVGTransformList.prototype.createSVGTransformFromMatrix = function(/*SVGMatrix*/ matrix ) {
2275 var t = new SVGTransform();
2276 t.setMatrix(matrix);
2279 /*SVGTransform*/ SVGTransformList.prototype.consolidate = function() {
2280 if(this.numberOfItems === 0) {
2283 var s = this.getItem(0), m = s.matrix;
2284 for (var i=1,nli=this.numberOfItems;i<nli;++i) {
2285 m = m.multiply(this.getItem(i).matrix);
2293 function SVGAnimatedTransformList() {
2294 /*readonly SVGTransformList*/ this.animVal = this.baseVal = new SVGTransformList();
2297 function SVGPreserveAspectRatio() {
2298 /*unsigned short*/ this.align = SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_XMIDYMID;
2299 /*unsigned short*/ this.meetOrSlice = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET;
2304 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_UNKNOWN = 0;
2305 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_NONE = 1;
2306 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMIN = 2;
2307 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3;
2308 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4;
2309 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMID = 5;
2310 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMID = 6;
2311 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMID = 7;
2312 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMINYMAX = 8;
2313 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9;
2314 /*unsigned short*/ t.SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10;
2315 // Meet-or-slice Types
2316 /*unsigned short*/ t.SVG_MEETORSLICE_UNKNOWN = 0;
2317 /*unsigned short*/ t.SVG_MEETORSLICE_MEET = 1;
2318 /*unsigned short*/ t.SVG_MEETORSLICE_SLICE = 2;
2319 })(SVGPreserveAspectRatio);
2321 function SVGAnimatedPreserveAspectRatio() {
2322 /*readonly SVGPreserveAspectRatio*/ this.animVal = this.baseVal = new SVGPreserveAspectRatio();
2326 function SVGPathSeg() {
2327 /*readonly unsigned short*/ this.pathSegType = SVGPathSeg.PATHSEG_UNKNOWN;
2328 /*readonly DOMString*/ this.pathSegTypeAsLetter = null;
2333 // Path Segment Types
2334 /*unsigned short*/ t.PATHSEG_UNKNOWN = 0;
2335 /*unsigned short*/ t.PATHSEG_CLOSEPATH = 1;
2336 /*unsigned short*/ t.PATHSEG_MOVETO_ABS = 2;
2337 /*unsigned short*/ t.PATHSEG_MOVETO_REL = 3;
2338 /*unsigned short*/ t.PATHSEG_LINETO_ABS = 4;
2339 /*unsigned short*/ t.PATHSEG_LINETO_REL = 5;
2340 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_ABS = 6;
2341 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_REL = 7;
2342 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_ABS = 8;
2343 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_REL = 9;
2344 /*unsigned short*/ t.PATHSEG_ARC_ABS = 10;
2345 /*unsigned short*/ t.PATHSEG_ARC_REL = 11;
2346 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_ABS = 12;
2347 /*unsigned short*/ t.PATHSEG_LINETO_HORIZONTAL_REL = 13;
2348 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_ABS = 14;
2349 /*unsigned short*/ t.PATHSEG_LINETO_VERTICAL_REL = 15;
2350 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS = 16;
2351 /*unsigned short*/ t.PATHSEG_CURVETO_CUBIC_SMOOTH_REL = 17;
2352 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS = 18;
2353 /*unsigned short*/ t.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL = 19;
2356 *軽量化のために、SVGPathSegの継承をしない。また、{}オブジェクトで代用する予定
2358 function SVGPathSegClosePath() {
2361 SVGPathSegClosePath.prototype = {
2362 pathSegType : SVGPathSeg.PATHSEG_CLOSEPATH,
2363 pathSegTypeAsLetter : "z"
2365 function SVGPathSegMovetoAbs() {
2370 SVGPathSegMovetoAbs.prototype = {
2371 pathSegType : SVGPathSeg.PATHSEG_MOVETO_ABS,
2372 pathSegTypeAsLetter : "M"
2374 function SVGPathSegMovetoRel() {
2379 SVGPathSegMovetoRel.prototype = {
2380 pathSegType : SVGPathSeg.PATHSEG_MOVETO_REL,
2381 pathSegTypeAsLetter : "m"
2383 function SVGPathSegLinetoAbs() {
2388 SVGPathSegLinetoAbs.prototype = {
2389 pathSegType : SVGPathSeg.PATHSEG_LINETO_ABS,
2390 pathSegTypeAsLetter : "L"
2392 function SVGPathSegLinetoRel() {
2397 SVGPathSegLinetoRel.prototype = {
2398 pathSegType : SVGPathSeg.PATHSEG_LINETO_REL,
2399 pathSegTypeAsLetter : "l"
2401 function SVGPathSegCurvetoCubicAbs() {
2410 SVGPathSegCurvetoCubicAbs.prototype = {
2411 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS,
2412 pathSegTypeAsLetter : "C"
2414 function SVGPathSegCurvetoCubicRel() {
2423 SVGPathSegCurvetoCubicRel.prototype = {
2424 pathSegType : SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL,
2425 pathSegTypeAsLetter : "c"
2427 function SVGPathSegCurvetoQuadraticAbs() {
2432 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS;
2433 this.pathSegTypeAsLetter = "Q";
2436 function SVGPathSegCurvetoQuadraticRel() {
2441 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL;
2442 this.pathSegTypeAsLetter = "q";
2446 function SVGPathSegArcAbs() {
2451 /*float*/ this.angle;
2454 SVGPathSegArcAbs.prototype = {
2455 /*boolean*/ largeArcFlag : true,
2456 /*boolean*/ sweepFlag : true,
2457 pathSegType : SVGPathSeg.PATHSEG_ARC_ABS,
2458 pathSegTypeAsLetter : "A"
2460 function SVGPathSegArcRel() {
2465 /*float*/ this.angle;
2468 SVGPathSegArcRel.prototype = {
2469 /*boolean*/ largeArcFlag : true,
2470 /*boolean*/ sweepFlag : true,
2471 pathSegType : SVGPathSeg.PATHSEG_ARC_REL,
2472 pathSegTypeAsLetter : "a"
2474 function SVGPathSegLinetoHorizontalAbs() {
2476 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS;
2477 this.pathSegTypeAsLetter = "H";
2480 function SVGPathSegLinetoHorizontalRel() {
2482 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL;
2483 this.pathSegTypeAsLetter = "h";
2486 function SVGPathSegLinetoVerticalAbs() {
2488 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS;
2489 this.pathSegTypeAsLetter = "V";
2492 function SVGPathSegLinetoVerticalRel() {
2494 this.pathSegType = SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL;
2495 this.pathSegTypeAsLetter = "v";
2498 function SVGPathSegCurvetoCubicSmoothAbs() {
2503 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS;
2504 this.pathSegTypeAsLetter = "S";
2507 function SVGPathSegCurvetoCubicSmoothRel() {
2512 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL;
2513 this.pathSegTypeAsLetter = "s";
2516 function SVGPathSegCurvetoQuadraticSmoothAbs() {
2519 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS;
2520 this.pathSegTypeAsLetter = "T";
2523 function SVGPathSegCurvetoQuadraticSmoothRel() {
2526 this.pathSegType = SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL;
2527 this.pathSegTypeAsLetter = "t";
2530 function SVGPathSegList() {
2533 for (var prop in SVGStringList.prototype) { //prototypeのコピーで継承を行う
2534 SVGPathSegList.prototype[prop] = SVGStringList.prototype[prop];
2537 /*documentは引数の変数として登録しておく*/
2538 (function(_doc, _math) {
2539 //freeArg関数はunloadで使う解放処理
2540 NAIBU.freeArg = function() {
2541 SVGPathElement = _doc = _math = void 0;
2543 //仮のfill属性とstroke属性の処理
2544 NAIBU._setPaint = function(tar, matrix) {
2545 /*以下では、スタイルシートを用いて、fill-とstroke-関連の
2546 *処理を行う。SVGPaintインターフェースをも用いる
2548 var tod = tar.ownerDocument,
2549 _doc = tod._document_,
2551 style = tod.defaultView.getComputedStyle(tar, ""),
2552 fill = style.getPropertyCSSValue("fill"),
2553 stroke = style.getPropertyCSSValue("stroke"),
2554 fp = fill.paintType,
2555 sp = stroke.paintType,
2557 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1,
2558 t, evtt, fillOpacity, strs, cursor, vis, disp,
2559 strokeElement, strokeOpacity, tgebtstroke, sgsw, w, h, swx, tsd, strokedasharray;
2563 /*あらかじめ、v:fill要素とv:stroke要素は消しておく*/
2564 while (el.firstChild) {
2565 el.removeChild(el.firstChild);
2567 if ((fp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
2568 if (fp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
2569 /*再度、設定。css.jsのsetPropertyを参照*/
2570 style.setProperty("color", style.getPropertyValue("color"));
2572 fillElement = _doc.createElement("v:fill");
2574 num = /*CSSPrimitiveValue.CSS_NUMBER*/ 1;
2575 fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
2576 fillOpacity = +(style.getPropertyValue("fill-opacity")) * style._list._opacity; //opacityを掛け合わせる
2577 if (fillOpacity < 1) {
2578 fillElement.setAttribute("opacity", fillOpacity+"");
2580 el.appendChild(fillElement);
2581 fillElement = fc = fillOpacity = void 0;
2582 } else if (fill.uri) {
2583 /*以下では、Gradation関連の要素に、イベントを渡すことで、
2586 t = tod.getElementById(fill.uri);
2588 evtt = tod.createEvent("MutationEvents");
2589 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
2590 evtt._tar = _doc.createElement("v:fill");
2591 evtt._style = style;
2593 t.dispatchEvent(evtt);
2594 if (t.localName !== "radialGradient") {
2595 el.appendChild(evtt._tar);
2600 el.filled = "false";
2602 if ((sp === /*SVGPaint.SVG_PAINTTYPE_RGBCOLOR*/ 1) || (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102)) {
2603 if (sp === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
2604 /*再度、設定。css.jsのsetPropertyを参照*/
2605 style.setProperty("color", style.getPropertyValue("color"));
2607 strokeElement = _doc.createElement("v:stroke");
2608 sgsw = style.getPropertyCSSValue("stroke-width");
2609 w = tod.documentElement.viewport.width;
2610 h = tod.documentElement.viewport.height;
2611 sgsw._percent = _math.sqrt((w*w + h*h) / 2);
2612 swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * _math.sqrt(_math.abs(matrix._determinant()));
2613 strokeElement.setAttribute("weight", swx + "px");
2614 sgsw = w = h = void 0;
2616 fc = stroke.rgbColor;
2617 strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
2618 strokeOpacity = +(style.getPropertyValue("stroke-opacity")) * (+(style.getPropertyValue("opacity"))); //opacityを掛け合わせる
2620 strokeOpacity *= swx; //太さが1px未満なら色を薄くする
2622 if (strokeOpacity < 1) {
2623 strokeElement.setAttribute("opacity", strokeOpacity+"");
2625 fc = strokeOpacity = void 0;
2627 strokeElement.setAttribute("miterlimit", style.getPropertyValue("stroke-miterlimit"));
2628 strokeElement.setAttribute("joinstyle", style.getPropertyValue("stroke-linejoin"));
2629 if (style.getPropertyValue("stroke-linecap") === "butt") {
2630 strokeElement.setAttribute("endcap", "flat");
2632 strokeElement.setAttribute("endcap", style.getPropertyValue("stroke-linecap"));
2634 tsd = style.getPropertyValue("stroke-dasharray");
2635 if (tsd !== "none") {
2636 if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
2637 strs = tsd.split(",");
2638 for (var i = 0, sli = strs.length; i < sli; ++i) {
2639 strs[i] = _math.ceil(+(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
2641 strokedasharray = strs.join(" ");
2642 if (strs.length % 2 === 1) {
2643 strokedasharray += " " + strokedasharray;
2646 strokeElement.setAttribute("dashstyle", strokedasharray);
2647 tsd = strs = void 0;
2649 el.appendChild(strokeElement);
2650 strokeElement = tsd = void 0;
2652 el.stroked = "false";
2654 cursor = style.getPropertyCSSValue("cursor");
2655 if (cursor && !cursor._isDefault) { //初期値でないならば
2656 el.style.cursor = cursor.cssText.split(":")[1];
2658 vis = style.getPropertyCSSValue("visibility");
2659 if (vis && !vis._isDefault) {
2660 el.style.visibility = vis.cssText.split(":")[1];
2662 disp = style.getPropertyCSSValue("display");
2663 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
2664 el.style.display = "none";
2665 } else if (disp && !disp._isDefault && (disp.indexOf("inline-block") === -1)) {
2666 el.style.display = "inline-block";
2668 tod = _doc = el = fill = stroke = sp = fp = style = cursor = tar = matrix = vis = disp = num = void 0;
2671 function SVGPathElement(_doc) {
2672 SVGElement.apply(this);
2673 this._tar = _doc.createElement("v:shape");
2674 //interface SVGAnimatedPathData
2675 var sp = SVGPathSegList;
2676 /*readonly SVGPathSegList*/ this.pathSegList = new sp();
2677 this.animatedPathSegList = this.pathSegList;
2678 /*readonly SVGPathSegList*/ this.normalizedPathSegList = new sp();
2680 this.animatedNormalizedPathSegList = this.normalizedPathSegList;
2681 /*readonly SVGAnimatedNumber*/ this.pathLength = new SVGAnimatedNumber();
2682 //以下は、d属性に変更があった場合の処理
2683 this.addEventListener("DOMAttrModified", this._attrModi, false);
2684 /*以下の処理は、このpath要素ノードがDOMツリーに追加されて初めて、
2685 *描画が開始されることを示す。つまり、appendChildで挿入されない限り、描画をしない。
2687 this.addEventListener("DOMNodeInserted", this._nodeInsert, false);
2690 SVGPathElement.constructor = SVGElement;
2691 SVGPathElement.prototype = new SVGElement();
2692 (function(_sproto) {
2693 _sproto._attrModi = function(evt){
2694 var tar = evt.target;
2695 if (evt.attrName === "d" && evt.newValue !== ""){
2696 /* d属性の値が空の場合は、描画を行わないようにする
2698 *SVG1.1 「8.3.9 The grammar for path data」の項目にある最後の文章を参照
2700 var tnl = tar.normalizedPathSegList,
2701 tlist = tar.pathSegList;
2702 if (tnl.numberOfItems > 0) {
2706 /*d属性の値を正規表現を用いて、二次元配列Dに変換している。もし、d属性の値が"M 20 30 L20 40"ならば、
2708 *D = [["M", 20, 30], ["L", 20 40]]
2710 var taco = tar._com,
2713 .replace(taco.isRa, " -")
2714 .replace(taco.isRb, " ")
2715 .replace(taco.isRc, ",$1 ")
2716 .replace(taco.isRd, ",$1 1")
2717 .replace(taco.isRe, "")
2724 tcc = tar.createSVGPathSegCurvetoCubicAbs,
2725 tcll = tar.createSVGPathSegLinetoAbs;
2726 for (var i=0;i<dli;++i) {
2727 var di = dd[i].match(sgs),
2729 for (var j=1, dii=di[0], dili=di.length; j < dili; ++j) {
2731 s = tcc(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
2733 } else if (isL[dii]) {
2734 s = tcll(+di[j], +di[j+1]);
2736 } else if (isM[dii]) {
2737 s = tar.createSVGPathSegMovetoAbs(+di[j], +di[j+1]);
2739 } else if (isZ[dii]) {
2740 s = tar.createSVGPathSegClosePath();
2741 } else if (dii === "A") {
2742 s = tar.createSVGPathSegArcAbs(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
2744 } else if (dii === "m") {
2745 s = tar.createSVGPathSegMovetoRel(+di[j], +di[j+1]);
2747 } else if (dii === "l") {
2748 s = tar.createSVGPathSegLinetoRel(+di[j], +di[j+1]);
2750 } else if (dii === "c") {
2751 s = tar.createSVGPathSegCurvetoCubicRel(+di[j+4], +di[j+5], +di[j], +di[j+1], +di[j+2], +di[j+3]);
2753 } else if (dii === "Q") {
2754 s = tar.createSVGPathSegCurvetoQuadraticAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2756 } else if (dii === "q") {
2757 s = tar.createSVGPathSegCurvetoQuadraticRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2759 } else if (dii === "a") {
2760 s = tar.createSVGPathSegArcRel(+di[j+5], +di[j+6], +di[j], +di[j+1], +di[j+2], +di[j+3], +di[j+4]);
2762 } else if (dii === "S") {
2763 s = tar.createSVGPathSegCurvetoCubicSmoothAbs(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2765 } else if (dii === "s") {
2766 s = tar.createSVGPathSegCurvetoCubicSmoothRel(+di[j+2], +di[j+3], +di[j], +di[j+1]);
2768 } else if (dii === "T") {
2769 s = tar.createSVGPathSegCurvetoQuadraticSmoothAbs(+di[j], +di[j+1]);
2771 } else if (dii === "t") {
2772 s = tar.createSVGPathSegCurvetoQuadraticSmoothRel(+di[j], +di[j+1]);
2774 } else if (dii === "H") {
2775 s = tar.createSVGPathSegLinetoHorizontalAbs(+di[j]);
2776 } else if (dii === "h") {
2777 s = tar.createSVGPathSegLinetoHorizontalRel(+di[j]);
2778 } else if (dii === "V") {
2779 s = tar.createSVGPathSegLinetoVerticalAbs(+di[j]);
2780 } else if (dii === "v") {
2781 s = tar.createSVGPathSegLinetoVerticalRel(+di[j]);
2783 s = new SVGPathSeg();
2785 tlist.appendItem(s);
2788 di = s = sgs = dd = void 0;
2789 /*以下の処理は、pathSegListからnormalizedPathSegListへの
2790 *変換をする処理。相対座標を絶対座標に変換して、M、L、Cコマンドに正規化していく
2792 var cx = 0, cy = 0, //現在セグメントの終了点の絶対座標を示す (相対座標を絶対座標に変換するときに使用)
2793 xn = 0, yn = 0, //T,tコマンドで仮想的な座標を算出するのに用いる。第一コントロール点
2794 startx = 0, starty = 0; //M,mコマンドにおける始点座標(Z,zコマンドで用いる)
2795 for (var j=0, tli=tlist.numberOfItems;j<tli;++j) {
2796 var ti = tlist.getItem(j),
2797 ts = ti.pathSegType,
2798 dii = ti.pathSegTypeAsLetter;
2799 if (ts === /*SVGPathSeg.PATHSEG_UNKNOWN*/ 0) {
2801 var rx = cx, ry = cy; //rx, ryは前のセグメントの終了点
2802 if (ts % 2 === 1) { //相対座標ならば
2811 } else if (isL[dii]) {
2813 } else if (isM[dii]) {
2815 /*Mコマンドが続いた場合は、2番目以降はLコマンドと解釈する
2816 *W3C SVG1.1の「8.3.2 The "moveto" commands」を参照
2817 *http://www.w3.org/TR/SVG11/paths.html#PathDataMovetoCommands
2819 var tg = tlist.getItem(j-1);
2820 if (tg.pathSegTypeAsLetter === "M") {
2821 tnl.appendItem(tcll(cx, cy));
2828 } else if (dii === "m") {
2830 var tg = tlist.getItem(j-1);
2831 if (tg.pathSegTypeAsLetter === "m") {
2832 tnl.appendItem(tcll(cx, cy));
2838 tnl.appendItem(tar.createSVGPathSegMovetoAbs(cx, cy));
2839 } else if (dii === "l") {
2840 tnl.appendItem(tcll(cx, cy));
2841 } else if (dii === "c") {
2842 tnl.appendItem(tcc(cx, cy, ti.x1+rx, ti.y1+ry, ti.x2+rx, ti.y2+ry));
2843 } else if (isZ[dii]) {
2847 } else if (dii === "Q") {
2850 //2次スプライン曲線は近似的な3次ベジェ曲線に変換している
2851 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));
2852 } else if (dii === "q") {
2853 var x1 = ti.x1 + rx, y1 = ti.y1 + ry;
2856 tnl.appendItem(tcc(cx, cy, (rx + 2*x1) / 3, (ry + 2*y1) / 3, (2*x1 + cx) / 3, (2*y1 + cy) / 3));
2858 } else if (dii === "A" || dii === "a") {
2859 (function(ti, cx, cy, rx, ry, tar, tnl) { //変数を隠蔽するためのfunction
2860 /*以下は、Arctoを複数のCuvetoに変換する処理
2861 *SVG 1.1 「F.6 Elliptical arc implementation notes」の章を参照
2862 *http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
2864 if (ti.r1 === 0 || ti.r2 === 0) {
2867 var fS = ti.sweepFlag,
2869 r1 = _math.abs(ti.r1),
2870 r2 = _math.abs(ti.r2),
2871 ctx = (rx - cx) / 2, cty = (ry - cy) / 2,
2872 cpsi = _math.cos(psai * _math.PI / 180),
2873 spsi = _math.sin(psai * _math.PI / 180),
2874 rxd = cpsi*ctx + spsi*cty,
2875 ryd = -1*spsi*ctx + cpsi*cty,
2876 rxdd = rxd * rxd, rydd = ryd * ryd,
2879 lamda = rxdd/r1x + rydd/r2y,
2882 r1 = _math.sqrt(lamda) * r1;
2883 r2 = _math.sqrt(lamda) * r2;
2887 if (ti.largeArcFlag === fS) {
2890 sds = seif * _math.sqrt((r1x*r2y - r1x*rydd - r2y*rxdd) / (r1x*rydd + r2y*rxdd));
2892 var txd = sds*r1*ryd / r2,
2893 tyd = -1 * sds*r2*rxd / r1,
2894 tx = cpsi*txd - spsi*tyd + (rx+cx)/2,
2895 ty = spsi*txd + cpsi*tyd + (ry+cy)/2,
2896 rad = _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1) - _math.atan2(0, 1),
2897 s1 = (rad >= 0) ? rad : 2 * _math.PI + rad,
2898 rad = _math.atan2((-ryd-tyd)/r2, (-rxd-txd)/r1) - _math.atan2((ryd-tyd)/r2, (rxd-txd)/r1),
2899 dr = (rad >= 0) ? rad : 2 * _math.PI + rad;
2900 if (!fS && dr > 0) {
2902 } else if (fS && dr < 0) {
2905 var sse = dr * 2 / _math.PI,
2906 seg = _math.ceil(sse<0 ? -1*sse : sse),
2908 t = 8/3 * _math.sin(segr/4) * _math.sin(segr/4) / _math.sin(segr/2),
2909 cpsir1 = cpsi * r1, cpsir2 = cpsi * r2,
2910 spsir1 = spsi * r1, spsir2 = spsi * r2,
2913 x2 = rx - t * (cpsir1*ms + spsir2*mc),
2914 y2 = ry - t * (spsir1*ms - cpsir2*mc);
2915 for (var n = 0; n < seg; ++n) {
2919 var x3 = cpsir1*mc - spsir2*ms + tx,
2920 y3 = spsir1*mc + cpsir2*ms + ty,
2921 dx = -t * (cpsir1*ms + spsir2*mc),
2922 dy = -t * (spsir1*ms - cpsir2*mc);
2923 tnl.appendItem(tcc(x3, y3, x2, y2, x3-dx, y3-dy));
2927 ti= cx= cy= rx= ry= tar= tnl = void 0;
2928 })(ti, cx, cy, rx, ry, tar, tnl);
2929 } else if (dii === "S") {
2931 var tg = tnl.getItem(tnl.numberOfItems-1);
2932 if (tg.pathSegTypeAsLetter === "C") {
2933 var x1 = 2*tg.x - tg.x2,
2934 y1 = 2*tg.y - tg.y2;
2935 } else { //前のコマンドがCでなければ、現在の座標を第1コントロール点に用いる
2943 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2, ti.y2));
2945 } else if (dii === "s") {
2947 var tg = tnl.getItem(tnl.numberOfItems-1);
2948 if (tg.pathSegTypeAsLetter === "C") {
2949 var x1 = 2*tg.x - tg.x2,
2950 y1 = 2*tg.y - tg.y2;
2959 tnl.appendItem(tcc(cx, cy, x1, y1, ti.x2+rx, ti.y2+ry));
2961 } else if (dii === "T" || dii === "t") {
2963 var tg = tlist.getItem(j-1);
2964 if ("QqTt".indexOf(tg.pathSegTypeAsLetter) > -1) {
2971 tnl.appendItem(tcc(cx, cy, (rx + 2*xn) / 3, (ry + 2*yn) / 3, (2*xn + cx) / 3, (2*yn + cy) / 3));
2975 } else if (dii === "H" || dii === "h") {
2976 tnl.appendItem(tcll(cx, ry));
2977 cy = ry; //勝手にti.yが0としているため
2978 } else if (dii === "V" || dii === "v") {
2979 tnl.appendItem(tcll(rx, cy));
2985 evt = tar = taco = cx = cy = xn = yn = startx = starty = tnl = tlist = ti = dii = ts = isZ = isM = isL = isC = s = tcc = tcll = void 0;
2987 _sproto._nodeInsert = function(evt){
2988 var tar = evt.target;
2989 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
2992 var tnext = tar.nextSibling,
2993 tpart = tar.parentNode._tar,
2995 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
2996 tpart.insertBefore(tar._tar, tnext._tar);
2997 } else if (tnext && !tnext._tar && tpart) {
2998 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
2999 *use要素や実体参照などは_tarプロパティがないことに注意
3002 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3003 tpart.insertBefore(tar._tar, tnext._tar);
3006 tnext = tnext.nextSibling;
3009 tpart.appendChild(tar._tar);
3011 } else if (!tnext && tpart) {
3012 tpart.appendChild(tar._tar);
3014 tnext = tpart = isLast = void 0;
3015 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._nodeInsertInto, false);
3018 _sproto._nodeInsertInto = function(evt){
3019 /*以下の処理は、normalizedpathSegListとCTMに基づいて、
3020 *SVGのd属性をVMLに変換していく処理である。
3022 var tar = evt.target,
3023 matrix = tar.getScreenCTM(),
3024 tlist = tar.normalizedPathSegList,
3026 ma = matrix.a, mb = matrix.b, mc = matrix.c, md = matrix.d, me = matrix.e, mf = matrix.f,
3027 cname = tar._com._nameCom,
3028 isZ = tar._com._isZ, isC = tar._com._isC,
3030 for (var i=0, tli=tlist.numberOfItems;i<tli;++i) {
3034 tps = ti.pathSegTypeAsLetter,
3037 /*CTM(mx)の行列と座標(x, y)の積を算出する。数学における表現は以下のとおり
3042 t += [mr(ma*ti.x1 + mc*ti.y1 + me),
3043 mr(mb*ti.x1 + md*ti.y1 + mf),
3044 mr(ma*ti.x2 + mc*ti.y2 + me),
3045 mr(mb*ti.x2 + md*ti.y2 + mf),
3046 mr(ma*tx + mc*ty + me),
3047 mr(mb*tx + md*ty + mf)].join(" ");
3048 } else if (!isZ[tps]) {
3049 t += mr(ma*tx + mc*ty + me)+ " " +mr(mb*tx + md*ty + mf);
3053 var vi = tar.ownerDocument.documentElement,
3056 tt.path = dat.join(" ");
3057 tt.coordsize = vi.width.baseVal.value + " " + vi.height.baseVal.value;
3058 NAIBU._setPaint(tar, matrix);
3059 delete tar._cacheMatrix;
3060 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;
3085 isRc : /([a-yA-Y])/g,
3090 /*float*/ _sproto.getTotalLength = function() {
3092 nl = this.normalizedPathSegList;
3093 for (var i=1,nln=nl.numberOfItems,ms=null;i<nln;++i) {
3094 var seg = nl.getItem(i);
3095 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
3096 var ps = nl.getItem(i-1);
3097 s += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3098 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
3099 var ps = nl.getItem(i-1), dd = 0;
3100 /*2点のハンドルを結んだ線分の3辺と、
3101 *セグメントの始点と終点を結んだ1辺を足して2で割ったものを、ベジェ曲線の距離の近似値とする
3104 *本来は積分とシンプソン法などの解析を使って、媒介曲線であるベジェ曲線の距離を割り出すのが、
3105 *精密であり望ましいが、ここでは時間がかかりすぎるので別の方法をとる
3107 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
3108 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3109 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3110 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3112 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
3113 var ps = nl.getItem(i-1), ms = nl.getItem(0);
3114 s += _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
3118 this.pathLength.baseVal = s;
3121 /*SVGPoint*/ _sproto.getPointAtLength = function(/*float*/ distance ) {
3122 var segn = this.getPathSegAtLength(distance),
3125 nl = this.normalizedPathSegList,
3126 seg = nl.getItem(segn),
3127 s = this.ownerDocument.documentElement.createSVGPoint();
3128 if ((segn-1) <= 0) {
3133 var ps = nl.getItem(segn-1);
3134 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
3135 var segl = _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3136 var t = (segl + this._dis) / segl;
3137 s.x = ps.x + t * (seg.x-ps.x);
3138 s.y = ps.y + t * (seg.y-ps.y);
3139 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
3141 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
3142 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3143 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3144 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3146 var t = (segl + this._dis) / segl;
3147 /*以下はベジェ曲線の公式について、パラメータtによってまとめて整理したものを、
3150 s.x = (3*seg.x1 + seg.x - 3*seg.x2 - ps.x) * _math.pow(t, 3)
3151 +3*(ps.x - 2*seg.x1 + seg.x2) * _math.pow(t, 2)
3152 +3*(seg.x1 - ps.x) * t
3154 s.y = (3*seg.y1 + seg.y - 3*seg.y2 - ps.y) * _math.pow(t, 3)
3155 +3*(ps.y - 2*seg.y1 + seg.y2) * _math.pow(t, 2)
3156 +3*(seg.y1 - ps.y) * t
3158 } else if (seg.pathSegType === SVGPathSeg.MOVETO_ABS) {
3161 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
3162 var ms = nl.getItem(0), segl = _math.sqrt(_math.pow((seg.x-mx.x), 2) + _math.pow((seg.y-ms.y), 2));
3163 var t = (segl + this._dis) / segl;
3164 s.x = ms.x + t * (seg.x-ms.x);
3165 s.y = ms.y + t * (seg.y-ms.y);
3169 /*unsigned long*/ _sproto.getPathSegAtLength = function(/*float*/ distance ) {
3170 var nl = this.normalizedPathSegList; //仕様ではpathSegList
3171 for (var i=0,nln=nl.numberOfItems,ms=null;i<nln;++i) {
3172 var seg = nl.getItem(i);
3173 if (seg.pathSegType === SVGPathSeg.PATHSEG_LINETO_ABS) {
3174 var ps = nl.getItem(i-1);
3175 distance -= _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3176 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS) {
3177 var ps = nl.getItem(i-1), dd = 0;
3178 dd += _math.sqrt(_math.pow((seg.x1-ps.x), 2) + _math.pow((seg.y1-ps.y), 2));
3179 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3180 dd += _math.sqrt(_math.pow((seg.x2-seg.x1), 2) + _math.pow((seg.y2-seg.y1), 2));
3181 dd += _math.sqrt(_math.pow((seg.x-ps.x), 2) + _math.pow((seg.y-ps.y), 2));
3184 } else if (seg.pathSegType === SVGPathSeg.PATHSEG_CLOSEPATH) {
3185 var ps = nl.getItem(i-1), ms = nl.getItem(0);
3186 distance -= _math.sqrt(_math.pow((ps.x-ms.x), 2) + _math.pow((ps.y-ms.y), 2));
3188 if (distance <= 0) {
3189 /*_disプロパティは前述のgetPointAtLengthメソッドで使う*/
3190 this._dis = distance;
3195 /*もし、distanceがパスの距離よりも長い場合、
3197 *なお、これはSVG1.1の仕様の想定外のこと
3199 return (nl.numberOfItems - 1);
3201 /*SVGPathSegClosePath*/ _sproto.createSVGPathSegClosePath = function() {
3202 var _SVGPathSegClosePath = SVGPathSegClosePath;
3203 return (new _SVGPathSegClosePath());
3205 /*SVGPathSegMovetoAbs*/ _sproto.createSVGPathSegMovetoAbs = function(/*float*/ x, /*float*/ y ) {
3206 var _SVGPathSegMovetoAbs = SVGPathSegMovetoAbs, s = new _SVGPathSegMovetoAbs();
3211 /*SVGPathSegMovetoRel*/ _sproto.createSVGPathSegMovetoRel = function(/*float*/ x, /*float*/ y ) {
3212 var s = new SVGPathSegMovetoRel();
3217 /*SVGPathSegLinetoAbs*/ _sproto.createSVGPathSegLinetoAbs = function(/*float*/ x, /*float*/ y ) {
3218 var s = new SVGPathSegLinetoAbs();
3223 /*SVGPathSegLinetoRel*/ _sproto.createSVGPathSegLinetoRel = function(/*float*/ x, /*float*/ y ) {
3224 var s = new SVGPathSegLinetoRel();
3229 /*SVGPathSegCurvetoCubicAbs*/ _sproto.createSVGPathSegCurvetoCubicAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
3230 var _SVGPathSegCurvetoCubicAbs = SVGPathSegCurvetoCubicAbs, s = new _SVGPathSegCurvetoCubicAbs();
3239 /*SVGPathSegCurvetoCubicRel*/ _sproto.createSVGPathSegCurvetoCubicRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1, /*float*/ x2, /*float*/ y2 ) {
3240 var s = new SVGPathSegCurvetoCubicRel();
3249 /*SVGPathSegCurvetoQuadraticAbs*/ _sproto.createSVGPathSegCurvetoQuadraticAbs = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
3250 var s = new SVGPathSegCurvetoQuadraticAbs();
3257 /*SVGPathSegCurvetoQuadraticRel*/ _sproto.createSVGPathSegCurvetoQuadraticRel = function(/*float*/ x, /*float*/ y, /*float*/ x1, /*float*/ y1 ) {
3258 var s = new SVGPathSegCurvetoQuadraticRel();
3265 /*SVGPathSegArcAbs*/ _sproto.createSVGPathSegArcAbs = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
3266 var s = new SVGPathSegArcAbs();
3272 s.largeArcFlag = largeArcFlag;
3273 s.sweepFlag = sweepFlag;
3276 /*SVGPathSegArcRel*/ _sproto.createSVGPathSegArcRel = function(/*float*/ x, /*float*/ y, /*float*/ r1, /*float*/ r2, /*float*/ angle, /*boolean*/ largeArcFlag, /*boolean*/ sweepFlag ) {
3277 var s = new SVGPathSegArcRel();
3283 s.largeArcFlag = largeArcFlag;
3284 s.sweepFlag = sweepFlag;
3287 /*SVGPathSegLinetoHorizontalAbs*/ _sproto.createSVGPathSegLinetoHorizontalAbs = function(/*float*/ x ) {
3288 var s = new SVGPathSegLinetoHorizontalAbs();
3290 s.y = 0; //DOMでは指定されていないが、変換処理が楽なので用いる
3293 /*SVGPathSegLinetoHorizontalRel*/ _sproto.createSVGPathSegLinetoHorizontalRel = function(/*float*/ x ) {
3294 var s = new SVGPathSegLinetoHorizontalRel();
3299 /*SVGPathSegLinetoVerticalAbs*/ _sproto.createSVGPathSegLinetoVerticalAbs = function(/*float*/ y ) {
3300 var s = new SVGPathSegLinetoVerticalAbs();
3305 /*SVGPathSegLinetoVerticalRel*/ _sproto.createSVGPathSegLinetoVerticalRel = function(/*float*/ y ) {
3306 var s = new SVGPathSegLinetoVerticalRel();
3311 /*SVGPathSegCurvetoCubicSmoothAbs*/ _sproto.createSVGPathSegCurvetoCubicSmoothAbs = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
3312 var s = new SVGPathSegCurvetoCubicSmoothAbs();
3319 /*SVGPathSegCurvetoCubicSmoothRel*/ _sproto.createSVGPathSegCurvetoCubicSmoothRel = function(/*float*/ x, /*float*/ y, /*float*/ x2, /*float*/ y2 ) {
3320 var s = new SVGPathSegCurvetoCubicSmoothRel();
3327 /*SVGPathSegCurvetoQuadraticSmoothAbs*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothAbs = function(/*float*/ x, /*float*/ y ) {
3328 var s = new SVGPathSegCurvetoQuadraticSmoothAbs();
3333 /*SVGPathSegCurvetoQuadraticSmoothRel*/ _sproto.createSVGPathSegCurvetoQuadraticSmoothRel = function(/*float*/ x, /*float*/ y ) {
3334 var s = new SVGPathSegCurvetoQuadraticSmoothRel();
3339 })(SVGPathElement.prototype)
3340 NAIBU.SVGPathElement = SVGPathElement; //IE8では、SVGPathElementはローカル変数
3343 function SVGRectElement(_doc) {
3344 SVGElement.apply(this);
3345 this._tar = _doc.createElement("v:shape");
3346 var slen = SVGAnimatedLength;
3347 /*readonly SVGAnimatedLength*/ this.x = new slen();
3348 /*readonly SVGAnimatedLength*/ this.y = new slen();
3349 /*readonly SVGAnimatedLength*/ this.width = new slen();
3350 /*readonly SVGAnimatedLength*/ this.height = new slen();
3351 /*readonly SVGAnimatedLength*/ this.rx = new slen();
3352 /*readonly SVGAnimatedLength*/ this.ry = new slen();
3353 _doc = slen = void 0;
3354 this.addEventListener("DOMNodeInserted", function(evt){
3355 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3358 var tar = evt.target,
3359 tnext = tar.nextSibling,
3360 tpart = tar.parentNode._tar,
3362 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3363 tpart.insertBefore(tar._tar, tnext._tar);
3364 } else if (tnext && !tnext._tar && tpart) {
3365 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3366 *use要素や実体参照などは_tarプロパティがないことに注意
3369 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3370 tpart.insertBefore(tar._tar, tnext._tar);
3373 tnext = tnext.nextSibling;
3376 tpart.appendChild(tar._tar);
3378 } else if (!tnext && tpart) {
3379 tpart.appendChild(tar._tar);
3381 tnext = tpart = isLast = void 0;
3382 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3383 var tar = evt.target,
3384 style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""),
3385 fontSize = parseFloat(style.getPropertyValue("font-size"));
3386 tar.x.baseVal._emToUnit(fontSize);
3387 tar.y.baseVal._emToUnit(fontSize);
3388 tar.width.baseVal._emToUnit(fontSize);
3389 tar.height.baseVal._emToUnit(fontSize);
3390 var rx = tar.getAttributeNS(null, "rx"),
3391 ry = tar.getAttributeNS(null, "ry"),
3392 x = tar.x.baseVal.value,
3393 y = tar.y.baseVal.value,
3394 xw = x + tar.width.baseVal.value,
3395 yh = y + tar.height.baseVal.value,
3397 if ((rx || ry) && (rx !== "0") && (ry !== "0")) {
3398 tar.rx.baseVal._emToUnit(fontSize);
3399 tar.ry.baseVal._emToUnit(fontSize);
3400 var thrx = tar.rx.baseVal,
3401 thry = tar.ry.baseVal,
3402 twidth = tar.width.baseVal.value,
3403 theight = tar.height.baseVal.value;
3404 thrx.value = rx ? thrx.value : thry.value;
3405 thry.value = ry ? thry.value : thrx.value;
3406 //rx属性が幅より大きければ、幅の半分を属性に設定(ry属性は高さと比較する)
3407 if (thrx.value > twidth / 2) {
3408 thrx.value = twidth / 2;
3410 if (thry.value > theight / 2) {
3411 thry.value = theight / 2;
3413 var rxv = thrx.value,
3415 rrx = rxv * 0.55228,
3416 rry = ryv * 0.55228,
3421 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];
3423 list = ["m",x,y, "l",x,yh, xw,yh, xw,y, "x e"];
3425 //以下は、配列listそのものをCTMで座標変換していく処理
3426 var par = tar.ownerDocument.documentElement,
3427 ctm = tar.getScreenCTM(),
3430 vi = tar.ownerDocument.documentElement,
3431 w = vi.width.baseVal.value,
3432 h = vi.height.baseVal.value,
3434 for (var i=0, lili=list.length;i<lili;) {
3435 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
3439 p = par.createSVGPoint();
3442 pmt = p.matrixTransform(ctm);
3443 list[i] = mr(pmt.x);
3445 list[i] = mr(pmt.y);
3449 dat = list.join(" ");
3452 ele.coordsize = w + " " + h;
3453 NAIBU._setPaint(tar, ctm);
3454 delete tar._cacheMatrix;
3455 evt = tar = style = list = mr = dat = ele = vi = fontSize = void 0;
3461 SVGRectElement.constructor = SVGElement;
3462 SVGRectElement.prototype = new SVGElement();
3464 function SVGCircleElement(_doc) {
3465 SVGElement.apply(this);
3466 this._tar = _doc.createElement("v:shape");
3467 var sl = SVGAnimatedLength;
3468 /*readonly SVGAnimatedLength*/ this.cx = new sl();
3469 /*readonly SVGAnimatedLength*/ this.cy = new sl();
3470 /*readonly SVGAnimatedLength*/ this.r = new sl();
3472 this.addEventListener("DOMNodeInserted", function(evt){
3473 var tar = evt.target;
3474 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3477 var tnext = tar.nextSibling,
3478 tpart = tar.parentNode._tar,
3480 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3481 tpart.insertBefore(tar._tar, tnext._tar);
3482 } else if (tnext && !tnext._tar && tpart) {
3483 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3484 *use要素や実体参照などは_tarプロパティがないことに注意
3487 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3488 tpart.insertBefore(tar._tar, tnext._tar);
3491 tnext = tnext.nextSibling;
3494 tpart.appendChild(tar._tar);
3496 } else if (!tnext && tpart) {
3497 tpart.appendChild(tar._tar);
3499 tnext = tpart = isLast = void 0;
3500 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3501 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
3502 var fontSize = parseFloat(style.getPropertyValue("font-size"));
3503 tar.cx.baseVal._emToUnit(fontSize);
3504 tar.cy.baseVal._emToUnit(fontSize);
3505 tar.r.baseVal._emToUnit(fontSize);
3506 var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = ry = tar.r.baseVal.value;
3507 var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
3508 var rrx = rx * 0.55228, rry = ry * 0.55228;
3509 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"];
3510 //以下は、配列listそのものをCTMで座標変換していく処理
3511 var par = tar.ownerDocument.documentElement,
3512 ctm = tar.getScreenCTM(),
3514 for (var i=0, lili=list.length;i<lili;) {
3515 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
3519 var p = par.createSVGPoint();
3522 var pmt = p.matrixTransform(ctm);
3523 list[i] = mr(pmt.x);
3525 list[i] = mr(pmt.y);
3529 var dat = list.join(" ");
3531 var ele = tar._tar, vi = tar.ownerDocument.documentElement;
3532 var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
3534 ele.coordsize = w + " " + h;
3535 NAIBU._setPaint(tar, ctm);
3536 delete tar._cacheMatrix;
3537 evt = tar = list = mr = style = fontSize = dat = ele = void 0;
3543 SVGCircleElement.constructor = SVGElement;
3544 SVGCircleElement.prototype = new SVGElement();
3546 function SVGEllipseElement(_doc) {
3547 SVGElement.apply(this);
3548 this._tar = _doc.createElement("v:shape");
3549 var sl = SVGAnimatedLength;
3550 /*readonly SVGAnimatedLength*/ this.cx = new sl();
3551 /*readonly SVGAnimatedLength*/ this.cy = new sl();
3552 /*readonly SVGAnimatedLength*/ this.rx = new sl();
3553 /*readonly SVGAnimatedLength*/ this.ry = new sl();
3555 this.addEventListener("DOMNodeInserted", function(evt){
3556 var tar = evt.target;
3557 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3560 var tnext = tar.nextSibling,
3561 tpart = tar.parentNode._tar,
3563 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3564 tpart.insertBefore(tar._tar, tnext._tar);
3565 } else if (tnext && !tnext._tar && tpart) {
3566 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3567 *use要素や実体参照などは_tarプロパティがないことに注意
3570 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3571 tpart.insertBefore(tar._tar, tnext._tar);
3574 tnext = tnext.nextSibling;
3577 tpart.appendChild(tar._tar);
3579 } else if (!tnext && tpart) {
3580 tpart.appendChild(tar._tar);
3582 tnext = tpart = isLast = void 0;
3583 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3584 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
3585 var fontSize = parseFloat(style.getPropertyValue("font-size"));
3586 tar.cx.baseVal._emToUnit(fontSize);
3587 tar.cy.baseVal._emToUnit(fontSize);
3588 tar.rx.baseVal._emToUnit(fontSize);
3589 tar.ry.baseVal._emToUnit(fontSize);
3590 var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = tar.rx.baseVal.value, ry = tar.ry.baseVal.value;
3591 var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx;
3592 var rrx = rx * 0.55228, rry = ry * 0.55228;
3593 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"];
3594 //以下は、配列listそのものをCTMで座標変換していく処理
3595 var par = tar.ownerDocument.documentElement,
3596 ctm = tar.getScreenCTM(),
3598 for (var i=0, lili=list.length;i<lili;) {
3599 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
3603 var p = par.createSVGPoint();
3606 var pmt = p.matrixTransform(ctm);
3607 list[i] = mr(pmt.x);
3609 list[i] = mr(pmt.y);
3613 var dat = list.join(" ");
3615 var ele = tar._tar, vi = tar.ownerDocument.documentElement;
3616 var w = vi.width.baseVal.value, h = vi.height.baseVal.value;
3618 ele.coordsize = w + " " + h;
3619 NAIBU._setPaint(tar, ctm);
3620 delete tar._cacheMatrix;
3621 evt = ele = tar = style = fontSize = dat = list = mr = ctm = w = h = void 0;
3627 SVGEllipseElement.constructor = SVGElement;
3628 SVGEllipseElement.prototype = new SVGElement();
3630 function SVGLineElement(_doc) {
3631 SVGElement.apply(this);
3632 this._tar = _doc.createElement("v:shape");
3633 var sl = SVGAnimatedLength;
3634 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
3635 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
3636 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
3637 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
3639 this.addEventListener("DOMNodeInserted", function(evt){
3640 var tar = evt.target;
3641 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3644 var tnext = tar.nextSibling,
3645 tpart = tar.parentNode._tar,
3647 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3648 tpart.insertBefore(tar._tar, tnext._tar);
3649 } else if (tnext && !tnext._tar && tpart) {
3650 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3651 *use要素や実体参照などは_tarプロパティがないことに注意
3654 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3655 tpart.insertBefore(tar._tar, tnext._tar);
3658 tnext = tnext.nextSibling;
3661 tpart.appendChild(tar._tar);
3663 } else if (!tnext && tpart) {
3664 tpart.appendChild(tar._tar);
3666 tnext = tpart = isLast = void 0;
3667 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3668 var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
3669 var fontSize = parseFloat(style.getPropertyValue("font-size"));
3670 tar.x1.baseVal._emToUnit(fontSize);
3671 tar.y1.baseVal._emToUnit(fontSize);
3672 tar.x2.baseVal._emToUnit(fontSize);
3673 tar.y2.baseVal._emToUnit(fontSize);
3674 //以下は、配列listそのものをCTMで座標変換していく処理
3675 var vi = tar.ownerDocument.documentElement,
3676 ctm = tar.getScreenCTM(),
3679 p = vi.createSVGPoint();
3680 p.x = tar.x1.baseVal.value;
3681 p.y = tar.y1.baseVal.value;
3682 var pmt = p.matrixTransform(ctm);
3683 dat += mr(pmt.x)+ " " +mr(pmt.y)+ " l ";
3684 p.x = tar.x2.baseVal.value;
3685 p.y = tar.y2.baseVal.value;
3686 pmt = p.matrixTransform(ctm);
3687 dat += mr(pmt.x)+ " " +mr(pmt.y);
3690 var ele = tar._tar, w = vi.width.baseVal.value, h = vi.height.baseVal.value;
3692 ele.coordsize = w + " " + h;
3693 NAIBU._setPaint(tar, ctm);
3694 delete tar._cacheMatrix;
3695 evt = ele = tar = style = fontSize = dat = list = mr = ctm = vi = w = h = void 0;
3701 SVGLineElement.constructor = SVGElement;
3702 SVGLineElement.prototype = new SVGElement();
3704 /*_GenericSVGPolyElementインターフェース
3705 * このインターフェースはpolygonとpolyline要素共通のインターフェースとして使用。
3706 * ファイルサイズを軽量にすることができる
3708 NAIBU._GenericSVGPolyElement = function (_doc, xclose) {
3709 SVGElement.apply(this);
3710 this._tar = _doc.createElement("v:shape");
3712 //interface SVGAnimatedPoints
3713 /*readonly SVGPointList*/ this.animatedPoints = this.points = new SVGPointList();
3714 this.addEventListener("DOMAttrModified", function(evt){
3715 var tar = evt.target;
3716 if (evt.attrName === "points") {
3717 var tp = tar.points, par = tar.ownerDocument.documentElement;
3718 var list = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/);
3719 for (var i=0, p, lili=list.length;i<lili;i+=2) {
3720 if (isNaN(list[i])) {
3724 p = par.createSVGPoint();
3725 p.x = parseFloat(list[i]);
3726 p.y = parseFloat(list[i+1]);
3730 evt = tar = list = tp = par = p = void 0;
3732 this.addEventListener("DOMNodeInserted", function(evt){
3733 var tar = evt.target;
3734 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
3737 var tnext = tar.nextSibling,
3738 tpart = tar.parentNode._tar,
3740 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
3741 tpart.insertBefore(tar._tar, tnext._tar);
3742 } else if (tnext && !tnext._tar && tpart) {
3743 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
3744 *use要素や実体参照などは_tarプロパティがないことに注意
3747 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
3748 tpart.insertBefore(tar._tar, tnext._tar);
3751 tnext = tnext.nextSibling;
3754 tpart.appendChild(tar._tar);
3756 } else if (!tnext && tpart) {
3757 tpart.appendChild(tar._tar);
3759 tnext = tpart = isLast = void 0;
3760 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
3761 var tar = evt.target,
3763 ctm = tar.getScreenCTM(),
3765 //以下は、配列listそのものをCTMで座標変換していく処理
3766 for (var i=0, list = [], lili=tp.numberOfItems;i<lili;++i) {
3767 var p = tp.getItem(i),
3768 pmt = p.matrixTransform(ctm);
3769 list[2*i] = mr(pmt.x);
3770 list[2*i + 1] = mr(pmt.y);
3773 list.splice(2, 0, "l");
3774 var dat = "m" + list.join(" ") + xclose,
3776 vi = tar.ownerDocument.documentElement;
3777 w = vi.width.baseVal.value,
3778 h = vi.height.baseVal.value;
3781 ele.coordsize = w + " " + h;
3782 NAIBU._setPaint(tar, ctm);
3783 delete tar._cacheMatrix;
3784 evt = ele = tar = dat = list = mr = ctm = w = h = vi = void 0;
3790 function SVGPolylineElement(_doc) {
3791 NAIBU._GenericSVGPolyElement.call(this, _doc, "e");
3795 SVGPolylineElement.constructor = SVGElement;
3796 SVGPolylineElement.prototype = new SVGElement();
3798 function SVGPolygonElement(_doc) {
3799 NAIBU._GenericSVGPolyElement.call(this, _doc, "x e");
3803 SVGPolygonElement.constructor = SVGElement;
3804 SVGPolygonElement.prototype = new SVGElement();
3806 function SVGTextContentElement(_doc) {
3807 SVGElement.apply(this);
3808 /*readonly SVGAnimatedLength*/ this.textLength = new SVGAnimatedLength();
3809 /*readonly SVGAnimatedEnumeration*/ this.lengthAdjust = new SVGAnimatedEnumeration(SVGTextContentElement.LENGTHADJUST_UNKNOWN);
3810 this.addEventListener("DOMNodeInserted", function(evt){
3811 var tar = evt.target, cur = evt.currentTarget;
3812 /*Bubblingフェーズの時にはもう、div要素をDOMツリーに挿入しておく必要があるため、
3813 *あらかじめ、Capturingフェーズで処理しておく
3815 if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.localName === "a") && (tar.namespaceURI === "http://www.w3.org/2000/svg") && tar.firstChild) {
3816 /*a要素の場合はtarをすりかえておく*/
3817 tar = tar.firstChild;
3819 if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar.nodeType === /*Node.TEXT_NODE*/ 3) && !!!tar._tars) {
3820 /*Textノードにdiv要素を格納したリストをプロパティとして蓄えておく*/
3822 var data = tar.data.replace(/^\s+/, "").replace(/\s+$/, "");
3824 data = data.split('');
3825 for (var i=0, tdli=data.length;i<tdli;++i) {
3826 var d = _doc.createElement("div"),
3828 dstyle.position = "absolute";
3829 dstyle.marginLeft = dstyle.marginRight = dstyle.marginTop = "0px";
3830 dstyle.paddingTop = dstyle.paddingLeft = "0px";
3831 dstyle.whiteSpace = "nowrap";
3832 dstyle.textIndent = "0px";
3833 d.appendChild(_doc.createTextNode(data[i]));
3834 tar._tars[tar._tars.length] = d;
3837 cur._length += tar._tars.length;
3838 } else if ((evt.eventPhase === /*Event.CAPTURING_PHASE*/ 1) && (tar instanceof SVGTextContentElement) && !!!tar._tars) {
3839 cur._length += tar._length;
3841 evt = tar = cur = void 0;
3847 t.constructor = SVGElement;
3848 t.prototype = new SVGElement();
3849 // lengthAdjust Types
3850 /*unsigned short*/ t.LENGTHADJUST_UNKNOWN = 0;
3851 /*unsigned short*/ t.LENGTHADJUST_SPACING = 1;
3852 /*unsigned short*/ t.LENGTHADJUST_SPACINGANDGLYPHS = 2;
3853 t.prototype._list = null; //文字の位置を格納しておくリストのキャッシュ
3854 t.prototype._length = 0; //全文字数
3855 t.prototype._stx = t.prototype._sty = 0; //初めの文字の位置
3856 t.prototype._chars = 0; //tspan (tref)要素が全体の何文字目から始まっているか
3857 t.prototype._isYokogaki = true; //横書きかどうか
3858 /*long*/ t.prototype.getNumberOfChars = function() {
3859 return (this._length);
3861 /*float*/ t.prototype.getComputedTextLength = function() {
3862 var l = this.textLength.baseVal;
3863 if ((l.value === 0) && (this.getNumberOfChars() > 0)) {
3864 /*何も設定されていない場合のみ、初期化を行う*/
3865 l.newValueSpecifiedUnits(SVGLength.SVG_LENGTHTYPE_NUMBER, this.getSubStringLength(0, this.getNumberOfChars()));
3868 return (this.textLength.baseVal.value);
3870 /*getSubStringLengthメソッド
3871 *charnum番目の文字からnchars+charnum-1番目までの文字列の長さを求めて返す
3873 /*float*/ t.prototype.getSubStringLength = function(/*unsigned long*/ charnum, /*unsigned long*/ nchars ) {
3877 var tg = this.getNumberOfChars();
3878 if (tg < (nchars+charnum)) {
3879 /*ncharsが文字列の長さよりも長くなってしまったときには、
3880 *文字列の末端までの長さを求めるとする(SVG1.1の仕様より)
3882 nchars = tg - charnum + 1;
3884 var end = this.getEndPositionOfChar(nchars+charnum-1), st = this.getStartPositionOfChar(charnum);
3885 if (this._isYokogaki) {
3886 var s = end.x - st.x;
3888 var s = end.y - st.y;
3890 tg = end = st = void 0;
3893 /*SVGPoint*/ t.prototype.getStartPositionOfChar = function (/*unsigned long*/ charnum ) {
3894 if (charnum > this.getNumberOfChars() || charnum < 0) {
3895 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
3898 ti = tar.firstChild,
3899 tp = tar.parentNode;
3902 var chars = tar._chars, //現在、何文字目にあるのか
3903 x = tar._stx, y = tar._sty, n = 0, //現在のテキスト位置と順番
3904 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
3905 isYokogaki = ((style.getPropertyValue("writing-mode")) === "lr-tb") ? true : false,
3906 fontSize = parseFloat(style.getPropertyValue("font-size")),
3907 tx = tar.x.baseVal, ty = tar.y.baseVal, tdx = tar.dx.baseVal, tdy = tar.dy.baseVal;
3909 if (tp && ((tp.localName === "text") ||(tp.localName === "tspan"))) {
3910 var ptx = tp.x.baseVal,
3912 ptdx = tp.dx.baseVal,
3913 ptdy = tp.dy.baseVal;
3915 var ptx = pty = ptdx = ptdy = {numberOfItems : 0};
3917 var kern = "f ijltIr.,:;'-\"()",
3918 akern = "1234567890abcdeghknopquvxyz",
3919 tt, alm, tdc, tcca, p, almx, almy, tlist, tg;
3920 if (isYokogaki && (tar.localName === "text")) {
3921 y += fontSize * 0.2;
3922 } else if (tar.localName === "text"){
3923 x -= fontSize * 0.5;
3926 if (ti.nodeType === /*Node.TEXT_NODE*/ 3) {
3928 /*tspan(tref)要素のx属性で指定された座標の個数よりも、文字数が多い場合は、祖先(親)のx属性を
3929 *使う。また、属性が指定されていないときも同様に祖先や親を使う。
3930 *もし、仮に祖先や親がx属性を指定されていなければ、現在のテキスト位置(変数xに格納している)を使う。
3931 *この処理はdx属性やdy、y属性でも同様とする
3933 *http://www.hcn.zaq.ne.jp/___/REC-SVG11-20030114/text.html
3935 *注意:ここでは、tspan要素だけではなく、text要素にも適用しているが、本来はtspan要素のみに処理させること
3937 for (var i=0, tli=tt.length;i<tli;++i) {
3938 if (n < ptx.numberOfItems - chars) {
3939 x = ptx.getItem(n).value;
3941 x -= fontSize * 0.5;
3943 } else if (n < tx.numberOfItems) {
3944 x = tx.getItem(n).value;
3946 x -= fontSize * 0.5;
3949 if (n < pty.numberOfItems - chars) {
3950 y = pty.getItem(n).value;
3952 y += fontSize * 0.2;
3954 } else if (n < ty.numberOfItems) {
3955 y = ty.getItem(n).value;
3957 y += fontSize * 0.2;
3960 if (n < ptdx.numberOfItems - chars) {
3961 x += ptdx.getItem(n).value;
3962 } else if (n < tdx.numberOfItems) {
3963 x += tdx.getItem(n).value;
3965 if (n < ptdy.numberOfItems - chars) {
3966 y += ptdy.getItem(n).value;
3967 } else if (n < tdy.numberOfItems) {
3968 y += tdy.getItem(n).value;
3972 //カーニングを求めて、字の幅を文字ごとに調整する
3973 tdc = ti.data.charAt(i);
3974 if (kern.indexOf(tdc) > -1) {
3975 alm = fontSize * 0.68;
3976 } else if (tdc === "s"){
3977 alm = fontSize * 0.52;
3978 } else if ((tdc === "C") || (tdc === "D") || (tdc === "M") || (tdc === "W") || (tdc === "G") || (tdc === "m")){
3979 alm = fontSize * 0.2;
3980 } else if (akern.indexOf(tdc) > -1){
3981 alm = fontSize * 0.45;
3983 alm = fontSize * 0.3;
3985 tcca = tdc.charCodeAt(0);
3986 if ((12288 <= tcca) && (tcca <= 65533)) {
3987 alm = -fontSize * 0.01;
3988 if ((tdc === "う") || (tdc === "く") || (tdc === "し") || (tdc === "ち")) {
3989 alm += fontSize * 0.2;
3994 tlist[tlist.length] = x;
3995 tlist[tlist.length] = y;
3996 tlist[tlist.length] = fontSize - alm;
4006 if (ti.parentNode && (ti.parentNode.localName === "a")) { //a要素が親である場合は、tiを親に戻しておく
4009 ti = ti.nextSibling;
4010 } else if (((ti.localName === "tspan") || (ti.localName === "tref"))
4011 && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
4012 /*現在のテキスト位置(x,y)の分だけ、tspan (tref)要素をずらしておく。
4018 p = ti.getStartPositionOfChar(ti.getNumberOfChars());
4023 almx = tlist[tlist.length-1];
4025 almy = tlist[tlist.length-1];
4027 x = tlist[tlist.length-3] + almx;
4028 y = tlist[tlist.length-2] + almy;
4029 tar._list = tar._list.concat(tlist);
4030 tg = ti.getNumberOfChars();
4033 ti = ti.nextSibling;
4034 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
4035 /*a要素のテキストノードも処理する*/
4038 ti = ti.nextSibling;
4041 tar._isYokogaki = isYokogaki //getEndPositionOfCharメソッドなどで使う
4043 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;
4044 var s = this.ownerDocument.documentElement.createSVGPoint();
4045 s.x = this._list[charnum*3];
4046 s.y = this._list[charnum*3 + 1];
4047 s = s.matrixTransform(this.getScreenCTM());
4051 /*SVGPoint*/ t.prototype.getEndPositionOfChar = function(/*unsigned long*/ charnum ) {
4052 if (charnum > this.getNumberOfChars() || charnum < 0) {
4053 throw (new DOMException(DOMException.INDEX_SIZE_ERR));
4055 var s = this.getStartPositionOfChar(charnum);
4056 //アドバンス値(すなわちフォントの大きさ)をCTMの行列式を用いて、算出する
4057 var n = this._list[charnum*3 + 2] * Math.sqrt(Math.abs(this.getScreenCTM()._determinant()));
4058 if (this._isYokogaki) {
4066 /*SVGRect*/ t.prototype.getExtentOfChar = function(/*unsigned long*/ charnum ) {
4069 /*float*/ t.prototype.getRotationOfChar = function(/*unsigned long*/ charnum ) {
4072 /*long*/ t.prototype.getCharNumAtPosition = function(/*SVGPoint*/ point ) {
4075 /*void*/ t.prototype.selectSubString = function(/*unsigned long*/ charnum,/*unsigned long*/ nchars ) {
4078 })(SVGTextContentElement);
4080 function SVGTextPositioningElement(_doc) {
4081 SVGTextContentElement.apply(this, arguments);
4082 var sl = SVGAnimatedLengthList;
4083 /*readonly SVGAnimatedLengthList*/ this.x = new sl();
4084 /*readonly SVGAnimatedLengthList*/ this.y = new sl();
4085 /*readonly SVGAnimatedLengthList*/ this.dx = new sl();
4086 /*readonly SVGAnimatedLengthList*/ this.dy = new sl();
4088 /*readonly SVGAnimatedNumberList*/ this.rotate = new SVGAnimatedNumberList();
4089 this.addEventListener("DOMAttrModified", function(evt){
4090 var tar = evt.target,
4091 name = evt.attrName,
4092 tod = tar.ownerDocument.documentElement,
4093 _parseFloat = parseFloat;
4094 if ((name === "x") || (name === "y") || (name === "dx") || (name === "dy")) {
4095 var enr = evt.newValue.replace(/^\s+|\s+$/g, "").split(/[\s,]+/),
4096 teas = tar[name].baseVal;
4097 for (var i=0, tli=enr.length;i<tli;++i) {
4098 var tea = tod.createSVGLength(),
4099 n = enr[i].slice(-1),
4101 if (n >= "0" && n <= "9") {
4102 type = /*SVGLength.SVG_LENGTHTYPE_NUMBER*/ 1;
4103 } else if (n === "%") {
4104 if ((name === "x") || (name === "dx")) {
4105 tea._percent *= tod.viewport.width;
4106 } else if ((name === "y") || (name === "dy")) {
4107 tea._percent *= tod.viewport.height;
4109 type = /*SVGLength.SVG_LENGTHTYPE_PERCENTAGE*/ 2;
4111 n = enr[i].slice(-2);
4113 var style = tar.ownerDocument.defaultView.getComputedStyle(tar, null);
4114 tea._percent *= _parseFloat(style.getPropertyValue("font-size"));
4116 type = /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3;
4117 } else if (n === "ex") {
4118 type = /*SVGLength.SVG_LENGTHTYPE_EXS*/ 4;
4119 } else if (n === "px") {
4120 type = /*SVGLength.SVG_LENGTHTYPE_PX*/ 5;
4121 } else if (n === "cm") {
4122 type = /*SVGLength.SVG_LENGTHTYPE_CM*/ 6;
4123 } else if (n === "mm") {
4124 type = /*SVGLength.SVG_LENGTHTYPE_MM*/ 7;
4125 } else if (n === "in") {
4126 type = /*SVGLength.SVG_LENGTHTYPE_IN*/ 8;
4127 } else if (n === "pt") {
4128 type = /*SVGLength.SVG_LENGTHTYPE_PT*/ 9;
4129 } else if (n === "pc") {
4130 type = /*SVGLength.SVG_LENGTHTYPE_PC*/ 10;
4133 var s = _parseFloat(enr[i]);
4134 s = isNaN(s) ? 0 : s;
4135 tea.newValueSpecifiedUnits(type, s);
4136 teas.appendItem(tea);
4142 this.addEventListener("DOMNodeInserted", function(evt){
4143 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4144 var tar = evt.target;
4145 if (tar.nodeType !== /*Node.TEXT_NODE*/ 3) {
4147 evt.currentTarget._list = null;
4153 this._tar = _doc.createElement("v:group");
4154 this._doc = _doc; //_docプロパティは_texto関数内で使われる
4156 this.addEventListener("DOMNodeInserted", function(evt){
4157 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4160 var tar = evt.target,
4161 tnext = tar.nextSibling,
4162 tpart = tar.parentNode._tar,
4164 if (tnext && tnext._tar && tpart && (tnext._tar.parentNode === tpart)) {
4165 tpart.insertBefore(tar._tar, tnext._tar);
4166 } else if (tnext && !tnext._tar && tpart) {
4167 /*以下の処理は、_tarプロパティがない要素オブジェクトがあるため、それに対処するもの
4168 *use要素や実体参照などは_tarプロパティがないことに注意
4171 if (tnext._tar && (tnext._tar.parentNode === tpart)) {
4172 tpart.insertBefore(tar._tar, tnext._tar);
4175 tnext = tnext.nextSibling;
4178 tpart.appendChild(tar._tar);
4180 } else if (!tnext && tpart) {
4181 tpart.appendChild(tar._tar);
4183 tnext = tpart = isLast = void 0;
4184 tar.addEventListener("DOMNodeInsertedIntoDocument", tar._texto, false);
4189 SVGTextPositioningElement.constructor = SVGTextContentElement;
4190 SVGTextPositioningElement.prototype = new SVGTextContentElement();
4191 SVGTextPositioningElement.prototype._texto = function(evt) {
4192 var tar = evt.target,
4193 ti = tar.firstChild,
4195 style = tar.ownerDocument.defaultView.getComputedStyle(tar, null),
4196 n = parseFloat(style.getPropertyValue("font-size")) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant())),
4197 tod = tar.ownerDocument.documentElement,
4198 ttpc = ttp, //ttpcはttpのキャッシュ
4199 tlen = tar.getComputedTextLength(),
4200 anchor = style.getPropertyValue("text-anchor"),
4201 tedeco = style.getPropertyValue("text-decoration"), //text-decorationは継承しないので、個々に設定する
4204 ttps.fontSize = n + "px";
4205 ttps.fontFamily = style.getPropertyValue("font-family");
4206 ttps.fontStyle = style.getPropertyValue("font-style");
4207 ttps.fontWeight = style.getPropertyValue("font-weight");
4208 /*ここでの変数jは前回ノードまでの総文字数*/
4209 for (var i=0, j=0, tli=tar.getNumberOfChars();i<tli;++i) {
4211 if (!!ti._tars && (ti._tars.length !== 0)) {
4212 var ij = (i > j) ? i - j : j - i
4213 var sty = ti._tars[ij].style,
4214 p = tar.getStartPositionOfChar(i);
4215 sty.position = "absolute";
4216 if (tar._isYokogaki) {
4217 if (anchor === "middle") {
4219 } else if (anchor === "end") {
4223 if (anchor === "middle") {
4225 } else if (anchor === "end") {
4229 sty.left = p.x + "px";
4230 sty.top = p.y + "px";
4233 sty.marginTop = tar._isYokogaki ? -n-5+ "px" : "-5px";
4234 sty.lineHeight = n+10+ "px";
4235 sty.textDecoration = tedeco;
4236 sty.display = "none"
4237 ttp.appendChild(ti._tars[ij]);
4240 if (ti.nodeName === "#text") {
4241 if ((ti.data.length+j) <= i+1) { //テキストノード内の文字をすべて処理し終えれば
4242 j = j + ti.data.length;
4243 if (ti.parentNode.localName === "a") {
4247 ti = ti.nextSibling;
4249 } else if (!!ti.getNumberOfChars) {
4250 if ((ti.getNumberOfChars()+j) <= i+1) {
4251 j = j + ti.getNumberOfChars();
4252 ti = ti.nextSibling;
4254 } else if ((ti.localName === "a") && (ti.namespaceURI === "http://www.w3.org/2000/svg") && ti.firstChild) {
4262 var color = style.getPropertyValue("fill"),
4263 cursor = style.getPropertyCSSValue("cursor"),
4264 vis = style.getPropertyCSSValue("visibility"),
4265 disp = style.getPropertyCSSValue("display"),
4266 tts = tar._tar.style,
4267 tft = tar.firstChild._tars, //空白のテキストノードの場合、tftがundefinedになる恐れがある
4268 ttt = tft[0] ? tft[0].innerText.charAt(0) : [""], //あらかじめ初期化しておく
4270 if (color === "none"){
4271 tts.color = "transparent";
4272 } else if (color.indexOf("url") === -1) {
4275 tts.color = "black";
4277 if (cursor && !cursor._isDefault) { //初期値でないならば
4278 var tc = cursor.cssText;
4279 tts.cursor = tc.split(":")[1];
4282 if ((tar.x.baseVal.numberOfItems === 1) && (tar.y.baseVal.numberOfItems === 1)
4283 && tar._isYokogaki && (tar.firstChild.nodeName === "#text")) {
4284 /*xとy属性が一つの値しか取らないとき、字詰めの処理をすべてブラウザに任せておく。
4285 *以下では、他のdiv要素のテキストをすべて、最初のdiv要素にまとめている
4287 for (var i=1, tli=tft.length;i<tli;++i) {
4289 ttt += tfti.innerText;
4290 tfti.parentNode.removeChild(tfti);
4292 //以下でinnerTextやinnerHTMLを使うのは、IE6でエラーとなる可能性がある
4293 if (tft[0] && tft[0].replaceChild) {
4294 tft[0].replaceChild(tar._doc.createTextNode(ttt), tft[0].firstChild);
4300 if (ttp.lastChild) {
4301 if (ttp.lastChild.nodeName !== "rect") {
4308 var backr = tar._doc.createElement("v:rect"),
4309 backrs = backr.style; //ずれを修正するためのもの
4310 backrs.width = backrs.height = "1px";
4311 backrs.left = backrs.top = "0px";
4312 backr.stroked = backr.filled = "false";
4313 ttp.appendChild(backr);
4315 if (vis && !vis._isDefault) {
4316 tts.visibility = vis.cssText.split(":")[1];
4318 /*dipslayプロパティだけはdiv要素の個々に設定しておく必要がある
4319 *なぜかといえば、div要素をdisplay:none;であらかじめ設定しているため。
4321 if (disp && !disp._isDefault && (disp.cssText.indexOf("none") > -1)) {
4323 } else if (disp && !disp._isDefault) {
4326 var jt = tar._tar.firstChild,
4329 jt.style.display = di;
4330 jt = jt.nextSibling;
4332 while (ae[j]) { //要素内部にあるa要素の処理
4333 for (var l=0, tli=ae[j]._tars.length;l<tli;++l) {
4334 ae[j]._tars[l].style.display = di;
4339 delete tar._cacheMatrix;
4340 ae = isRect = evt = tar = style = tedeco = tpp = ttpc = style = color = cursor = disp = vis = ttps = backr = backrs = di = tft = jt = void 0;
4343 function SVGTextElement(_doc) {
4344 SVGTextPositioningElement.apply(this, arguments);
4347 SVGTextElement.constructor = SVGTextPositioningElement;
4348 SVGTextElement.prototype = new SVGTextPositioningElement();
4350 function SVGTSpanElement() {
4351 SVGTextElement.apply(this, arguments);
4354 SVGTSpanElement.constructor = SVGTextPositioningElement;
4355 SVGTSpanElement.prototype = new SVGTextPositioningElement();
4357 function SVGTRefElement(_doc) {
4358 SVGTextPositioningElement.apply(this, arguments);
4359 this.addEventListener("DOMNodeInserted", function(evt){
4360 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4363 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
4365 this.addEventListener("S_Load", function(evt){
4366 var tar = evt.target,
4367 tic = tar._instance.firstChild;
4368 /*textノードのデータだけを処理*/
4369 while (tic && (tic.nodeName !== "#text")) {
4370 tic = tic.nextSibling;
4372 tic && tar.parentNode.insertBefore(tar.ownerDocument.importNode(tic, false), tar);
4373 evt.target = tar.parentNode;
4374 tar.parentNode._texto(evt);
4375 tar = tic = evtt = void 0;
4377 SVGURIReference.apply(this, arguments);
4380 SVGTRefElement.constructor = SVGTextPositioningElement;
4381 SVGTRefElement.prototype = new SVGTextPositioningElement();
4383 function SVGTextPathElement() {
4384 SVGTextContentElement.apply(this, arguments);
4385 /*readonly SVGAnimatedLength*/ this.startOffset;
4386 /*readonly SVGAnimatedEnumeration*/ this.method;
4387 /*readonly SVGAnimatedEnumeration*/ this.spacing;
4388 SVGURIReference.apply(this, arguments);
4391 SVGTextPathElement.constructor = SVGTextContentElement;
4392 SVGTextPathElement.prototype = new SVGTextContentElement();
4395 // textPath Method Types
4396 /*unsigned short*/ t.TEXTPATH_METHODTYPE_UNKNOWN = 0;
4397 /*unsigned short*/ t.TEXTPATH_METHODTYPE_ALIGN = 1;
4398 /*unsigned short*/ t.TEXTPATH_METHODTYPE_STRETCH = 2;
4399 // textPath Spacing Types
4400 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_UNKNOWN = 0;
4401 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_AUTO = 1;
4402 /*unsigned short*/ t.TEXTPATH_SPACINGTYPE_EXACT = 2;
4403 })(SVGTextPathElement);
4405 function SVGAltGlyphElement() {
4406 SVGTextPositioningElement.apply(this, arguments);
4407 /*DOMString*/ this.glyphRef;
4408 /*DOMString*/ this.format;
4409 SVGURIReference.apply(this, arguments);
4412 SVGAltGlyphElement.constructor = SVGTextPositioningElement;
4413 SVGAltGlyphElement.prototype = new SVGTextPositioningElement();
4415 function SVGAltGlyphDefElement() {
4416 SVGElement.apply(this, arguments);
4419 SVGAltGlyphDefElement.constructor = SVGElement;
4420 SVGAltGlyphDefElement.prototype = new SVGElement();
4422 function SVGAltGlyphItemElement() {
4423 SVGElement.apply(this, arguments);
4426 SVGAltGlyphItemElement.constructor = SVGElement;
4427 SVGAltGlyphItemElement.prototype = new SVGElement();
4429 function SVGGlyphRefElement() {
4430 SVGElement.apply(this, arguments);
4431 /*DOMString*/ this.glyphRef;
4432 /*DOMString*/ this.format;
4437 SVGURIReference.apply(this, arguments);
4440 SVGGlyphRefElement.constructor = SVGElement;
4441 SVGGlyphRefElement.prototype = new SVGElement();
4443 function SVGPaint() {
4444 SVGColor.apply(this, arguments);
4449 t.constructor = SVGColor;
4450 t.prototype = new SVGColor();
4452 /*unsigned short*/ t.SVG_PAINTTYPE_UNKNOWN = 0;
4453 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR = 1;
4454 /*unsigned short*/ t.SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR = 2;
4455 /*unsigned short*/ t.SVG_PAINTTYPE_NONE = 101;
4456 /*unsigned short*/ t.SVG_PAINTTYPE_CURRENTCOLOR = 102;
4457 /*unsigned short*/ t.SVG_PAINTTYPE_URI_NONE = 103;
4458 /*unsigned short*/ t.SVG_PAINTTYPE_URI_CURRENTCOLOR = 104;
4459 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR = 105;
4460 /*unsigned short*/ t.SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR = 106;
4461 /*unsigned short*/ t.SVG_PAINTTYPE_URI = 107;
4462 /*readonly unsigned short*/ t.prototype.paintType = t.SVG_PAINTTYPE_UNKNOWN;
4463 /*readonly DOMString*/ t.prototype.uri = null;
4464 /*void*/ t.prototype.setUri = function(/*DOMString*/ uri ) {
4465 this.setPaint(SVGPaint.SVG_PAINTTYPE_URI_NONE, uri, null, null);
4467 /*void*/ t.prototype.setPaint = function(/*unsigned short*/ paintType, /*DOMString*/ uri, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ) {
4468 if ((paintType < 101 && uri) || (paintType > 102 && !uri)) {
4469 throw new SVGException(SVGException.SVG_INVALID_VALUE_ERR);
4472 this.paintType = paintType;
4473 if (paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) {
4474 paintType = /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3;
4476 this.setColor(paintType, rgbColor, iccColor); //SVGColorのsetColorメソッドを用いる
4478 // raises( SVGException );
4482 function SVGMarkerElement(){
4483 SVGElement.apply(this);
4484 var sl = SVGAnimatedLength;
4485 /*readonly SVGAnimatedLength*/ this.refX = new sl();
4486 /*readonly SVGAnimatedLength*/ this.refY = new sl();
4487 /*readonly SVGAnimatedEnumeration*/ this.markerUnits = new SVGAnimatedEnumeration();
4488 /*readonly SVGAnimatedLength*/ this.markerWidth = new sl();
4489 /*readonly SVGAnimatedLength*/ this.markerHeight = new sl();
4491 /*readonly SVGAnimatedEnumeration*/ this.orientType = new SVGAnimatedEnumeration();
4492 /*readonly SVGAnimatedAngle*/ this.orientAngle = new SVGAnimatedAngle();
4493 //SVGFitToViewBoxのインターフェースを用いる
4494 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
4495 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
4496 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
4500 // Marker Unit Types
4501 /*unsigned short*/ t.SVG_MARKERUNITS_UNKNOWN = 0;
4502 /*unsigned short*/ t.SVG_MARKERUNITS_USERSPACEONUSE = 1;
4503 /*unsigned short*/ t.SVG_MARKERUNITS_STROKEWIDTH = 2;
4504 // Marker Orientation Types
4505 /*unsigned short*/ t.SVG_MARKER_ORIENT_UNKNOWN = 0;
4506 /*unsigned short*/ t.SVG_MARKER_ORIENT_AUTO = 1;
4507 /*unsigned short*/ t.SVG_MARKER_ORIENT_ANGLE = 2;
4508 t.constructor = SVGElement;
4509 t.prototype = new SVGElement();
4510 /*void*/ t.prototype.setOrientToAuto = function() {
4513 /*void*/ t.prototype.setOrientToAngle = function(/*SVGAngle*/ angle ) {
4516 })(SVGMarkerElement);
4517 function SVGColorProfileElement() {
4518 SVGElement.apply(this);
4519 /*DOMString*/ this._local;
4520 // raises DOMException on setting
4521 // (NOTE: is prefixed by "_"
4522 // as "local" is an IDL keyword. The
4523 // prefix will be removed upon processing)
4524 /*DOMString*/ this.name;
4525 /*unsigned short*/ this.renderingIntent;
4526 SVGURIReference.apply(this, arguments);
4529 SVGColorProfileElement.constructor = SVGElement;
4530 SVGColorProfileElement.prototype = new SVGElement();
4532 function SVGColorProfileRule() {
4533 SVGCSSRule.apply(this);
4534 /*DOMString*/ this.src;
4535 /*DOMString*/ this.name;
4536 /*unsigned short*/ this.renderingIntent;
4539 SVGColorProfileRule.constructor = SVGCSSRule;
4540 SVGColorProfileRule.prototype = new SVGCSSRule();
4542 function SVGGradientElement() {
4543 SVGElement.apply(this);
4544 SVGURIReference.apply(this);
4545 /*readonly SVGAnimatedEnumeration*/ this.gradientUnits = new SVGAnimatedEnumeration();
4546 /*readonly SVGAnimatedTransformList*/ this.gradientTransform = new SVGAnimatedTransformList();
4547 /*readonly SVGAnimatedEnumeration*/ this.spreadMethod = new SVGAnimatedEnumeration();
4548 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4549 var grad = evt.target,
4551 t = evt._style, //eleはv:fill要素やv:stroke要素のノード、tはラップした要素ノードのスタイルを収納
4553 href, stops, length,
4558 if (!ele || !grad) { //まだ、path要素などが設定されていない場合
4559 grad = ele = t = grad2 = href = stops = length = color = colors = opacity = void 0;
4562 if (grad._instance) { //xlink言語で呼び出されたノードが_instanceに収納されているならば
4563 grad2 = grad._instance;
4565 stops = grad2.getElementsByTagNameNS("http://www.w3.org/2000/svg", "stop");
4567 ele = t = href = grad = grad2 = stops = color = colors = opacity = void 0;
4570 length = stops.length;
4571 for (var i = 0; i < length; ++i) {
4573 sstyle = stop.ownerDocument.defaultView.getComputedStyle(stop, "");
4574 ci = sstyle.getPropertyCSSValue("stop-color");
4575 if (ci && (ci.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3)) {
4576 /*再度、設定。css.jsのsetPropertyを参照*/
4577 sstyle.setProperty("color", sstyle.getPropertyValue("color"));
4579 color[i] = "rgb(" +ci.rgbColor.red.getFloatValue(1)+ "," +ci.rgbColor.green.getFloatValue(1)+ "," +ci.rgbColor.blue.getFloatValue(1)+ ")";
4580 colors[i] = stop.offset.baseVal + " " + color[i];
4581 opacity[i] = (sstyle.getPropertyValue("stop-opacity") || 1) * t.getPropertyValue("fill-opacity") * t.getPropertyValue("opacity");
4583 ele["method"] = "none";
4584 ele["color"] = color[0];
4585 ele["color2"] = color[length-1];
4586 ele["colors"] = colors.join(",");
4587 // When colors attribute is used, the meanings of opacity and o:opacity2 are reversed.
4588 ele["opacity"] = opacity[length-1]+ "";
4589 ele["o:opacity2"] = opacity[0]+ "";
4590 /*SVGRadialGradientElementインターフェースで利用する*/
4591 grad._color = color;
4592 var gt = grad2.getAttributeNS(null, "gradientTransform");
4594 grad.setAttributeNS(null, "transform", gt);
4596 grad = grad2 = ele = stops = length = color = colors = opacity = evt = t = href = stop = sstyle = ci = void 0;
4600 SVGGradientElement.constructor = SVGElement;
4601 SVGGradientElement.prototype = new SVGElement();
4602 // Spread Method Types
4603 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_UNKNOWN = 0;
4604 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_PAD = 1;
4605 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REFLECT = 2;
4606 /*unsigned short*/ SVGGradientElement.SVG_SPREADMETHOD_REPEAT = 3;
4608 function SVGLinearGradientElement() {
4609 SVGGradientElement.apply(this);
4610 var sl = SVGAnimatedLength;
4611 /*readonly SVGAnimatedLength*/ this.x1 = new sl();
4612 /*readonly SVGAnimatedLength*/ this.y1 = new sl();
4613 /*readonly SVGAnimatedLength*/ this.x2 = new sl();
4614 /*readonly SVGAnimatedLength*/ this.y2 = new sl();
4616 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4617 var grad = evt.target, ele = evt._tar, angle = 270;
4618 if (!!!ele) { //まだ、path要素などが設定されていない場合
4621 var style = grad.ownerDocument.defaultView.getComputedStyle(grad, "");
4622 var fontSize = parseFloat(style.getPropertyValue("font-size"));
4623 grad.x1.baseVal._emToUnit(fontSize);
4624 grad.y1.baseVal._emToUnit(fontSize);
4625 grad.x2.baseVal._emToUnit(fontSize);
4626 grad.y2.baseVal._emToUnit(fontSize);
4627 angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI;
4631 ele.setAttribute("type", "gradient");
4632 ele.setAttribute("angle", angle + "");
4633 evt = ele = grad = angle = style = fontSize = void 0;
4637 SVGLinearGradientElement.constructor = SVGGradientElement;
4638 SVGLinearGradientElement.prototype = new SVGGradientElement();
4640 function SVGRadialGradientElement(_doc) {
4641 SVGGradientElement.apply(this);
4642 var sl = SVGAnimatedLength;
4643 /*readonly SVGAnimatedLength*/ this.cx = new sl();
4644 /*readonly SVGAnimatedLength*/ this.cy = new sl();
4645 /*readonly SVGAnimatedLength*/ this.r = new sl();
4646 /*readonly SVGAnimatedLength*/ this.fx = new sl();
4647 /*readonly SVGAnimatedLength*/ this.fy = new sl();
4649 this.cx.baseVal.value = this.cy.baseVal.value = this.r.baseVal.value = 0.5;
4650 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
4651 var grad = evt.target,
4653 tar = evt._ttar; //eleはv:fill要素。tarはターゲットとになる要素
4654 if (!!!ele) { //まだ、path要素などが設定されていない場合
4657 ele.setAttribute("type", "gradientTitle");
4658 ele.setAttribute("focus", "100%");
4659 ele.setAttribute("focusposition", "0.5 0.5");
4660 if (tar.localName === "rect") {
4661 /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、
4662 *四角だとおかしな模様が出てしまう。以下はそれを避ける処理
4664 var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""),
4665 fontSize = parseFloat(style.getPropertyValue("font-size"));
4666 grad.cx.baseVal._emToUnit(fontSize);
4667 grad.cy.baseVal._emToUnit(fontSize);
4668 grad.r.baseVal._emToUnit(fontSize);
4669 grad.fx.baseVal._emToUnit(fontSize);
4670 grad.fy.baseVal._emToUnit(fontSize);
4671 var cx = grad.cx.baseVal.value,
4672 cy = grad.cy.baseVal.value,
4673 r = grad.r.baseVal.value,
4677 var tarrect = tar.getBBox(),
4678 vi = tar.ownerDocument.documentElement.viewport,
4683 units = grad.getAttributeNS(null, "gradientUnits");
4684 if (!units || units === "objectBoundingBox") {
4685 //%の場合は小数点に変換(10% -> 0.1)
4686 cx = cx > 1 ? cx/100 : cx;
4687 cy = cy > 1 ? cy/100 : cy;
4688 r = r > 1 ? r/100 : r;
4689 //要素の境界領域を求める(四隅の座標を求める)
4692 wid = tarrect.width,
4693 hei = tarrect.height;
4698 nx = ny = wid = hei = void 0;
4700 var matrix = tar.getScreenCTM().multiply(grad.getCTM());
4705 var rrx = rx * 0.55228,
4707 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"];
4708 for (var i = 0, lili = list.length; i < lili;) {
4709 if (isNaN(list[i])) { //コマンド文字は読み飛ばす
4713 var p = grad.ownerDocument.documentElement.createSVGPoint();
4714 p.x = parseFloat(list[i]);
4715 p.y = parseFloat(list[i+1]);
4716 var pmt = p.matrixTransform(matrix);
4717 list[i] = mr(pmt.x);
4719 list[i] = mr(pmt.y);
4723 var ellipse = list.join(" "),
4724 outline = _doc.getElementById("_NAIBU_outline"),
4725 background = _doc.createElement("div"),
4726 bstyle = background.style;
4727 bstyle.position = "absolute";
4728 bstyle.display = "inline-block";
4731 bstyle.textAlign = "left";
4733 bstyle.left = "0px";
4734 bstyle.width = w+ "px";
4735 bstyle.height = h+ "px";
4736 outline.appendChild(background);
4737 bstyle.filter = "progid:DXImageTransform.Microsoft.Compositor";
4738 background.filters.item('DXImageTransform.Microsoft.Compositor').Function = 23;
4739 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>',
4740 data = tar._tar.path.value;
4741 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>';
4742 background.filters[0].apply();
4743 background.innerHTML = circle;
4744 background.filters[0].play();
4745 tar._tar.parentNode.insertBefore(background, tar._tar);
4746 tar._tar.filled = "false";
4747 ellipse = outline = background = style = fontSize = bstyle = circle = data = list = mr = gt = cx = cy = r = w = h = matrix = void 0;
4748 } else if (!ele.parentNode){
4749 tar._tar.appendChild(ele);
4751 evt = tar = ele = gard = void 0;
4755 SVGRadialGradientElement.constructor = SVGGradientElement;
4756 SVGRadialGradientElement.prototype = new SVGGradientElement();
4758 function SVGStopElement() {
4759 SVGElement.apply(this, arguments);
4760 /*readonly SVGAnimatedNumber*/ this.offset = new SVGAnimatedNumber();
4761 this.addEventListener("DOMAttrModified", function(evt) {
4762 if (evt.attrName === "offset") {
4763 evt.target.offset.baseVal = parseFloat(evt.newValue);
4769 SVGStopElement.constructor = SVGElement;
4770 SVGStopElement.prototype = new SVGElement();
4772 function SVGPatternElement() {
4773 SVGElement.apply(this);
4774 var sl = SVGAnimatedLength;
4775 /*readonly SVGAnimatedEnumeration*/ this.patternUnits = new SVGAnimatedEnumeration();
4776 /*readonly SVGAnimatedEnumeration*/ this.patternContentUnits = new SVGAnimatedEnumeration();
4777 /*readonly SVGAnimatedTransformList*/ this.patternTransform = new SVGAnimatedTransformList();
4778 /*readonly SVGAnimatedLength*/ this.x = new sl();
4779 /*readonly SVGAnimatedLength*/ this.y = new sl();
4780 /*readonly SVGAnimatedLength*/ this.width = new sl();
4781 /*readonly SVGAnimatedLength*/ this.height = new sl();
4783 SVGURIReference.apply(this, arguments);
4784 //SVGFitToViewBoxのインターフェースを用いる
4785 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
4786 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
4787 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
4790 SVGPatternElement.constructor = SVGElement;
4791 SVGPatternElement.prototype = new SVGElement();
4793 function SVGClipPathElement() {
4794 SVGElement.apply(this, arguments);
4795 /*readonly SVGAnimatedEnumeration*/ this.clipPathUnits = new SVGAnimatedEnumeration();
4798 SVGClipPathElement.constructor = SVGElement;
4799 SVGClipPathElement.prototype = new SVGElement();
4801 function SVGMaskElement() {
4802 SVGElement.apply(this);
4803 var sl = SVGAnimatedLength;
4804 /*readonly SVGAnimatedEnumeration*/ this.maskUnits = new SVGAnimatedEnumeration();
4805 /*readonly SVGAnimatedEnumeration*/ this.maskContentUnits = new SVGAnimatedEnumeration();
4806 /*readonly SVGAnimatedLength*/ this.x = new sl();
4807 /*readonly SVGAnimatedLength*/ this.y = new sl();
4808 /*readonly SVGAnimatedLength*/ this.width = new sl();
4809 /*readonly SVGAnimatedLength*/ this.height = new sl();
4813 SVGMaskElement.constructor = SVGElement;
4814 SVGMaskElement.prototype = new SVGElement();
4816 function SVGFilterElement() {
4817 SVGElement.apply(this);
4818 var sl = SVGAnimatedLength;
4819 /*readonly SVGAnimatedEnumeration*/ this.filterUnits = new SVGAnimatedEnumeration();
4820 /*readonly SVGAnimatedEnumeration*/ this.primitiveUnits = new SVGAnimatedEnumeration();
4821 /*readonly SVGAnimatedLength*/ this.x = new sl();
4822 /*readonly SVGAnimatedLength*/ this.y = new sl();
4823 /*readonly SVGAnimatedLength*/ this.width = new sl();
4824 /*readonly SVGAnimatedLength*/ this.height = new sl();
4826 /*readonly SVGAnimatedInteger*/ this.filterResX = new SVGAnimatedInteger();
4827 /*readonly SVGAnimatedInteger*/ this.filterResY = new SVGAnimatedInteger();
4828 SVGURIReference.apply(this, arguments);
4829 //setFilterRes (/*unsigned long*/ filterResX,/*unsigned long*/ filterResY );
4832 SVGFilterElement.constructor = SVGElement;
4833 SVGFilterElement.prototype = new SVGElement();
4835 function SVGFilterPrimitiveStandardAttributes(ele) {
4836 SVGStylable.apply(this, arguments);
4838 var sl = SVGAnimatedLength;
4839 /*readonly SVGAnimatedLength*/ this.x = new sl();
4840 /*readonly SVGAnimatedLength*/ this.y = new sl();
4841 /*readonly SVGAnimatedLength*/ this.width = new sl();
4842 /*readonly SVGAnimatedLength*/ this.height = new sl();
4843 /*readonly SVGAnimatedString*/ this.result = new sl();
4846 SVGFilterPrimitiveStandardAttributes.constructor = SVGStylable;
4847 SVGFilterPrimitiveStandardAttributes.prototype = new SVGStylable();
4849 function SVGFEBlendElement() {
4850 SVGElement.apply(this, arguments);
4851 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
4852 /*readonly SVGAnimatedString*/ this.in2 = new SVGAnimatedString();
4853 /*readonly SVGAnimatedEnumeration*/ this.mode = new SVGAnimatedEnumeration();
4854 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
4857 SVGFEBlendElement.constructor = SVGElement;
4858 SVGFEBlendElement.prototype = new SVGElement();
4860 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_UNKNOWN = 0;
4861 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_NORMAL = 1;
4862 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_MULTIPLY = 2;
4863 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_SCREEN = 3;
4864 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_DARKEN = 4;
4865 /*unsigned short*/ SVGFEBlendElement.SVG_FEBLEND_MODE_LIGHTEN = 5;
4867 function SVGFEGaussianBlurElement() {
4868 SVGElement.apply(this, arguments);
4869 /*readonly SVGAnimatedString*/ this.in1 = new SVGAnimatedString();
4870 /*readonly SVGAnimatedNumber*/ this.stdDeviationX = new SVGAnimatedNumber();
4871 /*readonly SVGAnimatedNumber*/ this.stdDeviationY = new SVGAnimatedNumber();
4872 this._fpsa = SVGFilterPrimitiveStandardAttributes(this);
4875 SVGFEGaussianBlurElement.constructor = SVGElement;
4876 SVGFEGaussianBlurElement.prototype = new SVGElement();
4877 /*void*/ SVGFEGaussianBlurElement.prototype.setStdDeviation = function(/*float*/ stdDeviationX, /*float*/ stdDeviationY ) {
4881 function SVGCursorElement() {
4882 SVGElement.apply(this, arguments);
4883 /*readonly SVGAnimatedLength*/ this.x = new SVGAnimatedLength();
4884 /*readonly SVGAnimatedLength*/ this.y = new SVGAnimatedLength();
4885 SVGURIReference.apply(this, arguments);
4888 SVGCursorElement.constructor = SVGElement;
4889 SVGCursorElement.prototype = new SVGElement();
4891 function SVGAElement(_doc) {
4892 SVGElement.apply(this);
4893 this._tar = _doc.createElement("a");
4895 /*readonly SVGAnimatedString*/ this.target = new SVGAnimatedString();
4896 this.target.baseVal = "_self";
4897 this.addEventListener("DOMAttrModified", function(evt){
4898 var tar = evt.target;
4899 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4902 if (evt.attrName === "target") {
4903 tar.target.baseVal = evt.newValue;
4904 } else if (evt.attrName === "xlink:title") {
4905 tar._tar.setAttribute("title", evt.newValue);
4909 this.addEventListener("DOMNodeInserted", function(evt){
4910 var tar = evt.target;
4911 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
4914 if (tar.nextSibling) {
4915 if (!!tar.parentNode._tar && !!tar.nextSibling._tar) {
4916 tar.parentNode._tar.insertBefore(tar._tar, tar.nextSibling._tar);
4918 } else if (!!tar.parentNode._tar){
4919 tar.parentNode._tar.appendChild(tar._tar);
4921 var txts = tar._tar.style;
4922 txts.cursor = "hand";
4925 txts.textDecoration = "none";
4927 var t = tar.target.baseVal;
4929 if (t === "_blank") {
4932 tar.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", st);
4933 tar._tar.style.color = tar.ownerDocument.defaultView.getComputedStyle(tar, "").getPropertyValue("fill");
4936 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4937 var tar = evt.target;
4938 if (!!tar._tar && (tar.nodeType === /*Node.ELEMENT_NODE*/ 1)) {
4939 var txts = tar._tar.style;
4940 txts.cursor = "hand";
4941 txts.textDecoration = "none";
4947 this.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
4948 var tar = evt.target;
4949 tar._tar.setAttribute("target", tar.target.baseVal);
4950 if (tar.href.baseVal.indexOf(".svg") !== -1) { //もし、リンク先がSVGファイルならば
4951 tar.addEventListener("click", function(evt){
4952 var tar = evt.target,
4955 sd.lastChild.innerHTML = "<object data='" +tar.href.baseVal.split("#")[0]+ "' width='" +screen.width+ "' height='" +screen.height+ "' type='image/svg+xml'></object>";
4956 if (tar.target.baseVal === "_self") {
4957 nd = tar.ownerDocument._iframe;
4958 nd.parentNode.insertBefore(sd.lastChild.firstChild, nd);
4959 ob = nd.nextSibling;
4960 if (ob && (ob.tagName === "OBJECT")) {
4961 nd.previousSibling.setAttribute("width", ob.getAttribute("width"));
4962 nd.previousSibling.setAttribute("height", ob.getAttribute("height"));
4963 nd.parentNode.removeChild(ob);
4965 ob = NAIBU._search([nd.previousSibling]);
4966 nd.parentNode.removeChild(nd);
4968 sd.appendChild(sd.lastChild.firstChild);
4969 while (sd.firstChild !== sd.lastChild) { //オブジェクト要素以外を除去
4970 sd.removeChild(sd.firstChild);
4972 ob = NAIBU._search([sd.lastChild]);
4974 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
4975 evt.preventDefault();
4977 _init: (function (ob) {
4979 document.title = ob.getSVGDocument().title;
4985 sd = ob = nd = void 0;
4990 SVGURIReference.apply(this, arguments);
4993 SVGAElement.constructor = SVGElement;
4994 SVGAElement.prototype = new SVGElement();
4996 function SVGViewElement() {
4997 SVGElement.apply(this, arguments);
4998 /*readonly SVGStringList*/ this.viewTarget = new SVGStringList();
4999 //SVGFitToViewBoxのインターフェースを用いる
5000 /*readonly SVGAnimatedRect*/ this.viewBox = new SVGAnimatedRect();
5001 /*readonly SVGAnimatedPreserveAspectRatio*/ this.preserveAspectRatio = new SVGAnimatedPreserveAspectRatio();
5002 /*unsigned short*/ this.zoomAndPan = SVGZoomAndPan.SVG_ZOOMANDPAN_DISABLE;
5005 SVGViewElement.constructor = SVGElement;
5006 SVGViewElement.prototype = new SVGElement();
5008 function SVGScriptElement() {
5009 SVGElement.apply(this);
5010 /*DOMString*/ this.type;
5011 SVGURIReference.apply(this, arguments);
5012 this.addEventListener("DOMAttrModified", function(evt){
5013 if (evt.attrName === "type") {
5014 evt.target.type = evt.newValue;
5018 this.addEventListener("S_Load", function(evt){
5019 var tar = evt.target, script = tar._text;
5020 var tod = tar.ownerDocument;
5021 NAIBU._temp_doc = tod;
5022 script = script.replace(/function\s+(\w+)/g, "$1 = function");
5023 script = "(function(document){" +script+ "})(NAIBU._temp_doc);"
5026 } catch (e) { //IE9では、documentがconstとして定数指定されているため、引数として指定できない
5027 script = script.replace(/function\(document\){/, "function() {");
5030 tar = evt = script = void 0;
5032 this.addEventListener("DOMNodeInserted", function(evt){
5033 var tar = evt.target;
5034 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5035 if (tar.nodeName === "#cdata-section") {
5036 evt.currentTarget._text = tar.data;
5040 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5041 var tar = evt.target;
5042 if (evt.eventPhase === Event.AT_TARGET && !tar.getAttributeNodeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
5043 var evtt = tar.ownerDocument.createEvent("SVGEvents");
5044 evtt.initEvent("S_Load", false, false);
5045 evt.currentTarget.dispatchEvent(evtt);
5052 SVGScriptElement.constructor = SVGElement;
5053 SVGScriptElement.prototype = new SVGElement();
5055 function SVGEvent() {
5056 Event.apply(this, arguments);
5059 SVGEvent.constructor = Event;
5060 SVGEvent.prototype = new Event();
5062 function SVGZoomEvent() {
5063 UIEvent.apply(this, arguments);
5064 /*readonly SVGRect*/ this.zoomRectScreen = new SVGRect();
5065 /*readonly float*/ this.previousScale = 1;
5066 /*readonly SVGPoint*/ this.previousTranslate = new SVGPoint();
5067 /*readonly float*/ this.newScale = 1;
5068 /*readonly SVGPoint*/ this.newTranslate = new SVGPoint();
5071 SVGZoomEvent.constructor = UIEvent;
5072 SVGZoomEvent.prototype = new UIEvent();
5074 function SVGAnimationElement(es) {
5078 SVGElement.apply(this);
5079 /*SIEにおけるSVGElementでは、fill属性とStyleSheetを結びつける機構があるため、
5080 *styleのsetPropertyメソッドを無効化させておく必要がある
5082 this.style.setProperty = function(){};
5084 /*readonly SVGElement*/ this.targetElement;
5085 /*それぞれのプロパティは、_を除いた属性に対応している*/
5086 this._begin = this._end = this._repeatCount = this._repeatDur = null;
5087 this._dur = "indefinite";
5088 this._currentFrame = 0;
5089 /*_maxCountはrepeatCount属性で指定された数値
5090 *_maxDurはrepeatDur属性で指定された数値
5094 /*_isRepeatと_numRepeatは繰り返し再生のときに使う。なお、後者は現在のリピート回数*/
5095 this._isRepeat = false;
5096 this._numRepeat = 0;
5097 /*_startと_finishプロパティはミリ秒数を収納する。
5098 *_startはアニメ開始時の秒数。_finishはアニメ終了時の秒数。
5099 *なお、文書読み込み終了時(アニメ開始時刻)の秒数を0とする。
5101 this._start = this._finish = null;
5102 this._from = this._to = this._values = this._by = null;
5103 this._keyTimes = null;
5104 this.addEventListener("beginEvent", function(evt) {
5106 var tar = evt.target,
5108 dur = tar.getSimpleDuration(),
5112 td = tar._repeatDur,
5113 tc = tar._repeatCount,
5115 /*Activate Duration (活性持続時間と呼ぶことにする)を計算
5117 *http://www.w3.org/TR/smil-animation/#ComputingActiveDur
5118 *3.3.4. Computing the active duration
5120 if ((td === "indefinte") || (tc === "indefinte")) {
5124 /*活性持続時間が不定(indefinte)なので、強制的にアニメを終了させる*/
5126 } else if (durv === "indefinte") {
5128 /*活性持続時間が不定(indefinte)なので、強制的にアニメを終了させる*/
5129 } else if (tc && !endv) {
5130 ac = tar._getOffset(td);
5131 } else if (!tc && endv) {
5134 ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
5136 } else if (durv && !td && !tc && !endv) {
5138 } else if (durv && !td && tc && !endv) {
5140 } else if (durv && td && !tc && !endv) {
5141 ac = tar._getOffset(td);
5142 } else if (durv && !td && !tc && endv) {
5143 ac = (dur > (end - begin)) ? dur : (end - begin);
5144 } else if (durv && td && tc && !endv) {
5145 ac = (+tc*dur > tar._getOffset(td)) ? +tc*dur : tar._getOffset(td);
5146 } else if (durv && td && tc && endv) {
5147 ac = (+tc*dur > Math.min(+td, (end-begin))) ? +tc*dur : Math.min(tar._getOffset(td), (end - begin));
5148 } else if (durv && td && !tc && endv) {
5149 ac = (tar._getOffset(td) > (end - begin)) ? tar._getOffset(td) : (end - begin);
5150 } else if (durv && !td && tc && endv) {
5151 ac = (+tc*dur > (end - begin)) ? +tc*dur : (end - begin)
5154 throw new DOMException(DOMException.INVALID_STATE_ERR);
5156 tar.endElementAt(active);
5157 tar.beginElementAt(tar.getSimpleDuration());
5158 if (tar.getCurrentTime() !== 0) {
5159 var ttd = tar.ownerDocument, evt = ttd.createEvent("TimeEvents");
5160 tar._currentCount++;
5161 evt.initTimeEvent("repeatEvent", ttd.defaultView, tar._numRepeat);
5162 tar.dispatchEvent(evt);
5165 this.addEventListener("DOMAttrModified", function(evt){
5166 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5169 var tar = evt.target,
5170 name = evt.attrName,
5171 evtv = evt.newValue;
5172 if (name === "begin") {
5174 } else if (name === "end") {
5176 } else if (name === "dur") {
5178 } else if (name === "repeatCount") {
5179 tar._maxCount = parseFloat(evtv);
5180 tar._repeatCount = evtv;
5181 tar._isRepeat = true;
5182 } else if (name === "repeatDur") {
5183 tar._maxDur = parseFloat(evtv);
5184 tar._repeatCount = evtv;
5185 tar._isRepeat = true;
5186 } else if (name === "from") {
5188 } else if (name === "to") {
5190 } else if (name === "values") {
5191 tar._values = evtv.split(";");
5192 } else if (name === "by") {
5194 } else if (name === "keyTimes") {
5195 var s = evtv.split(";");
5196 tar._keyTimes = []; //_keyTimesプロパティを初期化
5197 for (var i=0;i<s.length;++i) {
5198 tar._keyTimes[i] = parseFloat(s[i]);
5202 evt = evtv = void 0;
5204 this.addEventListener("DOMNodeInserted", function(evt){
5205 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5208 var tar = evt.target;
5209 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5210 var tar = evt.target;
5211 /*以降の場合分けルールに関しては、下記の仕様を参照
5212 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#AnimationNS-FromToBy
5215 } else if (tar._from && tar._to) {
5216 tar._values = [tar._from, tar._to];
5217 } else if (tar._from && tar._by) {
5218 var n = parseFloat(tar._from) + parseFloat(tar._by), tanni = tar._from.match(/\D+/) || [""];
5219 tar._values = [tar._from, n+tanni[0]];
5220 } else if (tar._to) {
5221 tar._values = [null, tar._to];
5222 } else if (tar._by) {
5223 tar._values = [null, null, tar._by];
5224 } else if (!tar.hasChildNodes() && !tar.hasAttributeNS(null, "path")) { //SVGAnimateMotionElementに留意
5225 /*アニメーションの効果が出ないように調整する
5228 *>if none of the from, to, by or values attributes are specified, the animation will have no effect
5229 *「3.2.2. Animation function values」より引用
5230 *http://www.w3.org/TR/2001/REC-smil-animation-20010904/#AnimFuncValues
5234 if (tar.hasAttributeNS("http://www.w3.org/1999/xlink", "xlink:href")) {
5235 tar.targetElement = tar.ownerDocument.getElementById(tar.getAttributeNS("http://www.w3.org/1999/xlink", "xlink:href").substring(1))
5237 tar.targetElement = tar.parentNode;
5243 this.addEventListener("repeatEvent", function(evt) {
5244 var tar = evt.target;
5246 if ((tar._currentCount >= tar._maxCount) || (tar.getCurrentTime() >= (tar._maxDur+tar.getStartTime()))) {
5247 tar._isRepeat = false;
5252 SVGAnimationElement.constructor = SVGElement;
5253 SVGAnimationElement.prototype = new SVGElement();
5254 /*以下のメソッド(beginElementなど)については、
5255 *別モジュールであるsmil::ElementTimeControl(smil.js)を参照のこと
5257 /*void*/ SVGAnimationElement.prototype.beginElement = function() {
5258 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
5259 evt.initTimeEvent("beginEvent", ttd.defaultView, 0);
5260 this.dispatchEvent(evt);
5262 /*void*/ SVGAnimationElement.prototype.endElement = function() {
5263 var ttd = this.ownerDocument, evt = ttd.createEvent("TimeEvents");
5264 evt.initTimeEvent("endEvent", ttd.defaultView, 0);
5265 this.dispatchEvent(evt);
5267 /*void*/ SVGAnimationElement.prototype.beginElementAt = function(/*float*/ offset) {
5268 var ntc = this.ownerDocument.documentElement.getCurrentTime();
5269 this._start = offset + ntc;
5271 /*void*/ SVGAnimationElement.prototype.endElementAt = function(/*float*/ offset) {
5272 var ntc = this.ownerDocument.documentElement.getCurrentTime();
5273 this._finish = offset + ntc;
5275 SVGAnimationElement.prototype._eventRegExp = /(mouse|activ|clic|begi|en)[a-z]+/;
5276 SVGAnimationElement.prototype._timeRegExp = /[\-\d\.]+(h|min|s|ms)?$/;
5277 SVGAnimationElement.prototype._unit = {
5284 * どれだけズレの時間があるかを計測するメソッド
5285 *tに数値が使われていないときは0を返す
5286 *これはSMILアニメーションモジュールの以下の記述にあるように、値のデフォルトが0であることに起因する
5287 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-Ex:0DurDiscreteMedia
5288 *http://www.w3.org/TR/2001/REC-smil20-20010807/smil-timing.html#Timing-DurValueSemantics
5289 ** Note that when the simple duration is "indefinite", some simple use cases can yield surprising results. See the related example #4 in Appendix B.
5291 SVGAnimationElement.prototype._getOffset = function(/*string*/ t) {
5292 var n = parseFloat(t.match(this._timeRegExp)),
5294 if (isFinite(n) && RegExp.$1) {
5295 var offset = n * this._unit[RegExp.$1]
5296 } else if (isFinite(n)) {
5303 /*float*/ SVGAnimationElement.prototype.getStartTime = function(){
5304 if (this._start || (this._start === 0)) {
5305 return (this._start);
5307 var _begin = this._begin ? this._getOffset(this._begin) : 0,
5309 timing = function(val, name, offset) {
5310 /*timing関数は時間のタイミングをidとeventと、clock-value(offset)に分割して処理していく
5311 *まず、idを検出するためのsearcIdローカル関数を作る
5313 var searchId = function () {
5314 var n = val.indexOf(".");
5315 if ((n > 0) && (/[a-z]/i).test(val.charAt(n+1))) { //. (dot)の後がアルファベットならば
5316 return (val.slice(0, n));
5323 *W3CのSMIl AnimationのTimingモデルは7パターンがあるので、場合分けする
5325 if (isFinite(parseFloat(val))) { //1) offset-valueの場合
5327 } else if (val.indexOf("repeat(") > -1) { //2) repeat-valueの場合
5328 var inte = parseFloat(val.slice(7)),
5329 ds = function (evt) {
5330 if (inte === evt.target._numRepeat) {
5336 that.ownerDocument.getElementById(id).addEventListener("repeatEvent", ds);
5338 that.addEventListener("repeatEvent", ds);
5340 } else if ((/\.(begin|end)/).test(val)) { //3) syncbase-valueの場合
5343 var ds = function (evt) {
5347 if (RegExp.$1 === "begin") {
5349 } else if (RegExp.$1 === "end") {
5352 that.ownerDocument.getElementById(id).addEventListener(ev, ds);
5354 } else if (val.indexOf("wallclock(") === 0) { //4) wallclock-valueの場合
5356 } else if (val === "indefinte") { //5) indefinteの場合
5357 } else if (val.indexOf("accesskey(") > -1) { //6) accesskey-valueの場合
5359 } else { //7) event-valueの場合
5361 var ds = function (evt) {
5364 if (id && val.match(/\.([a-z]+)/i)) {
5365 that.ownerDocument.getElementById(id).addEventListener(RegExp.$1, ds);
5367 that.targetElement.addEventListener(val.match(/^[a-z]+/i)[0], ds)
5370 val = searchId = id = void 0;
5372 timing((this._begin || "0ms"), "beginElementAt", _begin);
5374 timing(this._end, "endElementAt", this._getOffset(this._end));
5377 //throw new DOMException(DOMException.INVALID_STATE_ERR);
5380 /*getCurrentTimeメソッド
5382 *決して現在時刻ではない。要素のbeginイベントの発火したときが0sである。
5384 /*float*/ SVGAnimationElement.prototype.getCurrentTime = function(){
5385 return (this._currentFrame * 125 * 0.8);
5387 /*float*/ SVGAnimationElement.prototype.getSimpleDuration = function(){
5388 if (!this._dur && !this._finish && (this._dur === "indefinte")) {
5389 throw new DOMException(DOMException.NOT_SUPPORTED_ERR);
5391 return (this._getOffset(this._dur));
5394 //raises( DOMException );
5398 start : function() {
5399 if (NAIBU.Clip.length > 0) {
5400 screen.updateInterval = 42; //24fpsとして描画処理
5401 window.onscroll = function () {
5402 screen.updateInterval = 0;
5403 screen.updateInterval = 42;
5405 NAIBU.stop = setInterval( (function() {
5407 var ntc = NAIBU.Time.currentFrame + 1;
5408 var nc = NAIBU.Clip;
5409 var s = ntc * 100; //フレーム数ntcをミリ秒数sに変換 (100 = 125 * 0.8)
5410 if (ntc > NAIBU.Time.Max) {
5411 clearInterval(NAIBU.stop);
5413 nc[0] && nc[0].ownerDocument.documentElement.setCurrentTime(s);
5414 for (var i=0,ncli=nc.length;i<ncli;++i) {
5416 if ("_start" in nci) {
5417 if (nci.getStartTime() <= s) {
5418 if (nci.getCurrentTime() === 0) {
5421 nci._currentFrame++;
5423 if (nci._finish && (nci._finish <= s) && (nci.getCurrentTime() !== 0)) {
5425 nci._frame && nci._frame();
5426 nci._currentFrame = 0;
5429 } else if (!!nci._frame) {
5442 window.onscroll = function () {
5443 screen.updateInterval = 0;
5444 window.onscroll = NAIBU.emptyFunction;
5451 function SVGAnimateElement(){
5452 SVGAnimationElement.apply(this);
5453 /*NAIBU.Clipについては、NAIBU.Timeで使う
5454 *くわしくはNAIBU.Time.start関数のコードを参照
5456 NAIBU.Clip[NAIBU.Clip.length] = this;
5458 *機械が理解できる形で保管されているvalueの値の配列リスト
5460 this._valueList = [];
5461 this._isDiscrete = false;
5462 this.addEventListener("DOMAttrModified", function(evt){
5463 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5466 if ((evt.attrName === "calcMode") && (evt.newValue === "discrete")) {
5467 evt.target._isDiscrete = true;
5470 this.addEventListener("DOMNodeInserted", function(evt){
5471 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5474 var tar = evt.target;
5475 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5476 var tar = evt.target,
5477 attrName = tar.getAttributeNS(null, "attributeName"),
5478 ttr = tar.targetElement,
5479 tta = ttr[attrName];
5480 /*tar.valuesのリスト: ["12px", "13px"]
5481 *tar._valueList: [(new SVGPoint()), (new SVGPoint())]
5482 * tar.valuesを機械が理解できるように変換したものがtar._valueList
5483 *この_valueListプロパティはアニメの際に使うので、_valuesプロパティはアニメ中に使わないことに注意
5485 var vi = ttr.cloneNode(false);
5486 if (!tar._values[0]) { //to属性か、by属性が設定されている場合
5487 var ttrs = ttr.ownerDocument.defaultView.getComputedStyle(ttr, "");
5488 tar._values[0] = ttr.getAttributeNS(null, attrName) || ttrs.getPropertyValue(attrName);
5489 if (!tar._values[1] && tar._values[2]) { //by属性のみが設定されている場合
5490 var v2 = parseFloat(tar._values[0]) + parseFloat(tar._values[2]), tanni = tar._values[0].match(/\D+/) || [""];
5491 tar._values[1] = v2 + tanni[0];
5493 v2 = tanni = void 0;
5496 if ("animatedPoints" in ttr) {
5497 ttr.animatedPoints = vi.points;
5498 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5499 var vir = ttr.cloneNode(false);
5501 vir.setAttributeNS(null, "points", tav[i]);
5502 tar._valueList[tar._valueList.length] = vir.points;
5505 tta.animVal = vi[attrName].baseVal;
5506 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5507 var vir = ttr.cloneNode(false); //仮の要素
5509 vir.setAttributeNS(null, attrName, tav[i]);
5510 tar._valueList[tar._valueList.length] = vir[attrName].baseVal;
5512 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
5513 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5514 if ((attrName === "fill") || (attrName === "stroke") || (attrName === "stop-color")) {
5515 tar._valueList[i] = new SVGPaint();
5516 tar._valueList[i].setPaint(1, null, tav[i], null)
5518 tar._valueList[i] = parseFloat(tav[i]);
5521 } else if ("normalizedPathSegList" in ttr) {
5522 ttr.animatedNormalizedPathSegList = vi.normalizedPathSegList;
5523 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5524 var vir = ttr.cloneNode(false);
5526 vir.setAttributeNS(null, "d", tav[i]);
5527 tar._valueList[tar._valueList.length] = vir.normalizedPathSegList;
5533 evt = tta = vir = vi = void 0;
5536 this.addEventListener("beginEvent", function(evt) {
5537 var tar = evt.target;
5538 var attrName = tar.getAttributeNS(null, "attributeName"), newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName);
5539 var ttr = tar.targetElement, tta = ttr[attrName];
5540 tar._frame = function() {
5541 var d = tar.getSimpleDuration() * 0.8, n = tar._valueList.length-1, tg = tar.getCurrentTime();
5542 if ((n !== -1) && (d !== 0) && (tg <= d)) {
5543 if (tar._isDiscrete) {
5544 ++n; //discreteモードは他のモードに比べて、分割数が多いことに注意
5546 var ii = Math.floor((tg*n) / d);
5547 if (ii === n) { //iiが境い目のときは、n-2を適用
5553 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
5555 * 参照:アニメーションサンドイッチモデル
5556 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
5557 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
5559 var evt = tar.ownerDocument.createEvent("MutationEvents");
5560 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5561 if (tar._keyTimes) {
5562 var di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
5563 var ti = tar._keyTimes[ii];
5565 var di = d / n; //keyTimesがなければ均等に時間を配分しておく
5568 if ("animatedPoints" in ttr) {
5569 var base = ttr.points;
5570 ttr.points = ttr.animatedPoints;
5571 ttr.dispatchEvent(evt);
5572 ttr.animatedPoints = ttr.points;
5575 var base = tta.baseVal, tanim = tta.animVal;
5576 var v1 = tar._valueList[ii].value;
5577 /*vを求める公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
5578 * 3.4.2 Specifying the simple animation function f(t)
5579 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
5581 if (!tar._isDiscrete) {
5582 var v2 = tar._valueList[ii+1].value, v = v1 + (v2-v1) * (tg-ti*d) / di;
5586 tanim.newValueSpecifiedUnits(base.unitType, v);
5587 tta.baseVal = tanim;
5589 ttr.dispatchEvent(evt);
5590 /*変化値はanimValプロパティに収納しておき、
5591 *変化する前の、元の値はbaseValプロパティに再び収納しておく
5593 tta.animVal = tta.baseVal;
5596 } else if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
5598 var v1 = tar._valueList[ii].value, v2 = tar._valueList[ii+1].value;
5599 if (!tar._isDiscrete) {
5600 var v = v1 + (v2-v1) * (tg-ti*d) / di;
5604 } else if ("normalizedPathSegList" in ttr) {
5605 var base = ttr.normalizedPathSegList;
5606 ttr.normalizedPathSegList = ttr.animatedNormalizedPathSegList;
5607 ttr.dispatchEvent(evt);
5608 ttr.animatedNormalizedPathSegList = ttr.normalizedPathSegList;
5609 ttr.normalizedPathSegList = base;
5611 evt = v1 = v2 = v = d = n = ii = tg = void 0;
5615 this.addEventListener("endEvent", function(evt) {
5616 var tar = evt.target, fill = tar.getAttributeNS(null, "fill");
5617 if (!fill || (fill === "remove")) {
5618 var evt = tar.ownerDocument.createEvent("MutationEvents");
5619 evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5620 tar.targetElement.dispatchEvent(evt);
5624 this.addEventListener("repeatEvent", function(evt) {
5625 var tar = evt.target;
5629 SVGAnimateElement.constructor = SVGAnimationElement;
5630 SVGAnimateElement.prototype = new SVGAnimationElement(1);
5632 function SVGSetElement(){
5633 SVGAnimationElement.apply(this);
5634 NAIBU.Clip[NAIBU.Clip.length] = this;
5636 this.addEventListener("DOMAttrModified", function(evt) {
5637 var tar = evt.target, name = evt.attrName;
5638 if (name === "to") {
5639 tar._to = evt.newValue;
5641 tar = name = void 0;
5643 this.addEventListener("beginEvent", function(evt) {
5644 var tar = evt.target;
5645 if (tar.targetElement) {
5646 var attrName = tar.getAttributeNS(null, "attributeName"),
5647 newAttr = tar.targetElement.attributes.getNamedItemNS(null, attrName),
5648 tta = tar.targetElement[attrName];
5649 if (!!CSS2Properties[attrName] || attrName.indexOf("-") > -1) { //スタイルシートのプロパティならば
5650 var style = tar.ownerDocument.getOverrideStyle(tar.targetElement, "");
5651 style.setProperty(attrName, tar.getAttributeNS(null, "to"), null);
5654 var base = tta.baseVal;
5655 if (base instanceof SVGLength) {
5656 tta.baseVal = tar.ownerDocument.documentElement.createSVGLength();
5657 } else if (base instanceof SVGRect) {
5658 tta.baseVal = tar.ownerDocument.documentElement.createSVGRect();
5660 /*setAttrbute(NS)メソッドはDOM属性を書き換えるため利用しない。
5662 * 参照:アニメーションサンドイッチモデル
5663 * >アニメーションが起動している時,それは実際,DOMの中の属性値は変化しない。
5664 *http://www.jsa.or.jp/stdz/instac/syoukai/H13/H13annual_report/12/ngc-wg3/offline/smil_20_20020131/animation.html#animationNS-AnimationSandwichModel
5666 var evt = tar.ownerDocument.createEvent("MutationEvents");
5667 evt.initMutationEvent("DOMAttrModified", true, false, newAttr, newAttr, tar._to, attrName, MutationEvent.MODIFICATION);
5668 tar.targetElement.dispatchEvent(evt);
5670 /*変化値はanimValプロパティに収納しておき、
5671 *変化する前の、元の値はbaseValプロパティに再び収納しておく
5673 tta.animVal = tta.baseVal;
5677 evt = tar = attrName = void 0;
5679 this.addEventListener("endEvent", function(evt) {
5680 var tar = evt.target,
5681 fill = tar.getAttributeNS(null, "fill");
5682 if (!fill || (fill === "remove")) {
5683 var attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
5684 tar.targetElement.style.setProperty(attrName, style.getPropertyValue(attrName), null);
5685 var evtt = tar.ownerDocument.createEvent("MutationEvents");
5686 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5687 tar.targetElement.dispatchEvent(evtt);
5688 attrName = style = evtt = void 0;
5690 tar = fill = void 0;
5692 this.addEventListener("repeatEvent", function(evt) {
5693 var tar = evt.target, attrName = tar.getAttributeNS(null, "attributeName"), style = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
5697 SVGSetElement.constructor = SVGAnimationElement;
5698 SVGSetElement.prototype = new SVGAnimationElement(1);
5700 function SVGAnimateMotionElement(){
5701 SVGAnimationElement.apply(this);
5702 NAIBU.Clip[NAIBU.Clip.length] = this;
5703 this.addEventListener("DOMAttrModified", function(evt){
5704 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5707 var tar = evt.target,
5708 name = evt.attrName;
5709 if (name === "path") {
5710 var d = tar.ownerDocument.createElementNS("http://www.w3.org/2000/svg", "path");
5711 d.setAttributeNS(null, "d", evt.newValue);
5716 this.addEventListener("DOMNodeInserted", function(evt){
5717 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5720 var tar = evt.target;
5721 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5725 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5728 vlist[i] = [+ti[0], +ti[1]];
5730 tar._valueList = vlist;
5734 this.addEventListener("beginEvent", function(evt) {
5735 var tar = evt.target,
5736 trans = tar.targetElement.transform;
5737 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
5740 trans.animVal = new SVGTransformList();
5741 if (trans.baseVal.numberOfItems !== 0) {
5742 trans.baseVal.consolidate();
5743 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
5745 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
5747 tar._frame = function() {
5750 tgsd = _tar.getSimpleDuration(),
5752 tg = _tar.getCurrentTime(),
5758 if (tpn) { //path属性が指定されていた場合、tpnは属性値となる
5759 var st = tpn.getTotalLength() * tg / d, //stは現在に至るまでの距離
5760 p = tpn.getPointAtLength(st),
5761 trans = _tar.targetElement.transform;
5762 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
5763 var base = trans.baseVal;
5764 trans.baseVal = trans.animVal;
5765 _tar.targetElement._cacheMatrix = null;
5766 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
5767 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5768 _tar.targetElement.dispatchEvent(evtt);
5769 trans.baseVal = base;
5770 evtt = base = trans = st = p = void 0;
5771 } else if (tar._valueList) {
5772 var total = 0, //totalは総距離
5773 st = 0, //stは現在にいたるまでの距離
5774 tav = tar._valueList,
5776 if ((n !== -1) && (d !== 0) && (tg <= d)) {
5777 ii = Math.floor((tg*n) / d);
5778 if (ii === n) { //iiが境い目のときは、n-2を適用
5784 for (var i=1, tvli=tav.length;i<tvli;i+=2) {
5785 total += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
5787 for (var i=1;i<ii;i+=2) {
5788 st += Math.sqrt(Math.pow(tav[i][1] - tav[i-1][1], 2) + Math.pow(tav[i][0] - tav[i-1][0], 2));
5790 var p = tar.ownerDocument.documentElement.createSVGPoint(),
5791 trans = _tar.targetElement.transform;
5792 st = (st / total) * d;
5793 p.x = tav[ii][0] + (tav[ii+1][0] - tav[ii][0]) * (tg - st) / d;
5794 p.y = tav[ii][1] + (tav[ii+1][1] - tav[ii][1]) * (tg - st) / d;
5795 trans.animVal.getItem(trans.animVal.numberOfItems-1).setTranslate(p.x, p.y);
5796 var base = trans.baseVal;
5797 trans.baseVal = trans.animVal;
5798 _tar.targetElement._cacheMatrix = void 0;
5799 var evtt = _tar.ownerDocument.createEvent("MutationEvents");
5800 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5801 _tar.targetElement.dispatchEvent(evtt);
5802 trans.baseVal = base;
5803 evtt = base = trans = st = p = void 0;
5806 evt = trans = tpn = tgsd = void 0;
5808 this.addEventListener("endEvent", function(evt) {
5809 var tar = evt.target,
5810 trans = tar.targetElement.transform,
5811 fill = tar.getAttributeNS(null, "fill");
5812 if (!fill || (fill === "remove")) {
5813 trans.animVal = trans.baseVal;
5814 var evtt = tar.ownerDocument.createEvent("MutationEvents");
5815 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5816 tar.targetElement.dispatchEvent(evtt);
5818 tar._frame = evt = evtt = void 0;
5820 this.addEventListener("repeatEvent", function(evt) {
5821 var tar = evt.target;
5825 SVGAnimateMotionElement.constructor = SVGAnimationElement;
5826 SVGAnimateMotionElement.prototype = new SVGAnimationElement(1);
5828 function SVGMPathElement() /* :
5831 SVGExternalResourcesRequired*/ {
5832 SVGElement.apply(this);
5833 SVGURIReference.apply(this);
5836 SVGMPathElement.constructor = SVGElement;
5837 SVGMPathElement.prototype = new SVGElement();
5839 function SVGAnimateColorElement() {
5840 SVGAnimationElement.apply(this);
5841 NAIBU.Clip[NAIBU.Clip.length] = this;
5842 this._valueList = [];
5843 this.addEventListener("DOMNodeInserted", function(evt){
5844 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5847 var tar = evt.target;
5848 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5849 var tar = evt.target,
5850 attrName = tar.getAttributeNS(null, "attributeName"),
5851 ttr = tar.targetElement,
5852 fstyle = tar.ownerDocument.defaultView.getComputedStyle(ttr, ""),
5854 if (!tar._values[0]) {
5855 tar._values[0] = fstyle.getPropertyValue(attrName);
5857 for (var i=0, tav=tar._values, tvli=tav.length;i<tvli;++i) {
5858 var to = new SVGColor();
5859 if (tar._values[i] === "currentColor") {
5860 to.setRGBColor(fstyle.getPropertyValue("color") || "black");
5861 } else if (tar._values[i] === "inherit") {
5862 /*いったん、cssValueTypeプロパティをinheritに指定して、継承元のオブジェクトを取得*/
5863 css = fstyle.getPropertyCSSValue(attrName);
5864 n = css.cssValueType;
5865 css.cssValueType = /*CSSValue.CSS_INHERIT*/ 0;
5866 to = fstyle.getPropertyCSSValue(attrName);
5867 css.cssValueType = n;
5869 to.setRGBColor(tar._values[i]);
5871 tar._valueList[tar._valueList.length] = to;
5874 tar = ttr = fstyle = css = n = attrName = void 0;
5877 this.addEventListener("beginEvent", function(evt) {
5878 var tar = evt.target,
5879 attrName = tar.getAttributeNS(null, "attributeName"),
5880 style = tar.ownerDocument.getOverrideStyle(tar.targetElement, ""),
5881 fstyle = tar.ownerDocument.defaultView.getComputedStyle(tar.targetElement, "");
5882 tar._frame = function() {
5884 /*公式に関しては、SMIL2.0 Animation Moduleの単純アニメーション関数の項を参照
5885 * 3.4.2 Specifying the simple animation function f(t)
5886 *http://www.w3.org/TR/2005/REC-SMIL2-20050107/animation.html#animationNS-SpecifyingAnimationFunction
5888 var d = _tar.getSimpleDuration() * 0.8,
5889 n = _tar._valueList.length - 1,
5890 tg = _tar.getCurrentTime(),
5892 if ((n !== -1) && (d !== 0) && (tg <= d)) {
5893 ii = Math.floor((tg*n) / d);
5894 if (ii === n) { //iiが境い目のときは、n-2を適用
5900 if (tar._keyTimes) {
5901 di = (tar._keyTimes[ii+1] - tar._keyTimes[ii]) * d;
5902 ti = tar._keyTimes[ii];
5904 di = d / n; //keyTimesがなければ均等に時間を配分しておく
5907 var fc = _tar._valueList[ii].rgbColor,
5908 tc = _tar._valueList[ii+1].rgbColor,
5909 durd = (tg-ti*d) / di,
5910 num = CSSPrimitiveValue.CSS_NUMBER,
5911 fr = fc.red.getFloatValue(num),
5912 fg = fc.green.getFloatValue(num),
5913 fb = fc.blue.getFloatValue(num),
5914 r = fr + (tc.red.getFloatValue(num) - fr) * durd,
5915 g = fg + (tc.green.getFloatValue(num) - fg) * durd,
5916 b = fb + (tc.blue.getFloatValue(num) - fb) * durd;
5917 style.setProperty(attrName, "rgb(" +Math.ceil(r)+ "," +Math.ceil(g)+ "," +Math.ceil(b)+ ")", null);
5918 _tar = d = n = tg = fc = tc = fr = fg = fb = num = r = g = b = void 0;
5922 this.addEventListener("endEvent", function(evt) {
5923 var tar = evt.target;
5924 if (!fill || (fill === "remove")) {
5925 var evtt = tar.ownerDocument.createEvent("MutationEvents");
5926 evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
5927 tar.targetElement.dispatchEvent(evtt);
5929 tar._frame = evt = evtt = void 0;
5931 this.addEventListener("repeatEvent", function(evt) {
5932 var tar = evt.target;
5936 SVGAnimateColorElement.constructor = SVGAnimationElement;
5937 SVGAnimateColorElement.prototype = new SVGAnimationElement(1);
5939 function SVGAnimateTransformElement() {
5940 SVGAnimationElement.apply(this);
5941 NAIBU.Clip[NAIBU.Clip.length] = this;
5942 this.addEventListener("beginEvent", function(evt) {
5943 var tar = evt.target, trans = tar.targetElement.transform;
5944 /*アニメーション中に変化すべき値をanimValプロパティに入力して、
5947 trans.animVal = new SVGTransformList();
5948 if (trans.baseVal.numberOfItems !== 0) {
5949 trans.animVal.initialize(trans.baseVal.createSVGTransformFromMatrix(trans.baseVal.getItem(0).matrix));
5951 trans.animVal.appendItem(tar.ownerDocument.documentElement.createSVGTransform());
5953 this.addEventListener("endEvent", function(evt) {
5954 var tar = evt.target;
5956 this.addEventListener("repeatEvent", function(evt) {
5957 var tar = evt.target;
5961 SVGAnimateTransformElement.constructor = SVGAnimationElement;
5962 SVGAnimateTransformElement.prototype = new SVGAnimationElement(1);
5964 function SVGFontElement() /*:
5966 SVGExternalResourcesRequired,
5968 SVGElement.apply(this);
5969 /*_isExternalは外部から呼び出されたfont要素ならば、真(1)となる*/
5970 /*boolean or number*/ this._isExternal = 0;
5971 this.addEventListener("DOMNodeInserted", function(evt){
5972 var tar = evt.target;
5973 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
5976 tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt){
5977 var tar = evt.target, svgns = "http://www.w3.org/2000/svg", fontFace = tar.getElementsByTagNameNS(svgns, "font-face").item(0);
5978 var nefunc = function(evt){
5979 var svg = evt.target;
5981 var familyName = fontFace.getAttributeNS(null, "font-family");
5982 var textElements = tar.ownerDocument.getElementsByTagNameNS(svgns, "text");
5983 for (var i=0,_tar=tar,tli=textElements.length;i<tli;++i) {
5984 var ti = textElements[i], style = _tar.ownerDocument.defaultView.getComputedStyle(ti, '');
5985 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
5986 NAIBU._noie_createFont(ti, _tar, true);
5989 evt = tar = svg = curt = textElments = svgns = _tar = void 0;
5991 if (!fontFace.__isLinked || tar._isExternal) {
5992 tar.ownerDocument.documentElement._svgload_limited = 0;
5993 tar.ownerDocument.documentElement.addEventListener("SVGLoad", nefunc, false);
5999 SVGFontElement.constructor = SVGElement;
6000 SVGFontElement.prototype = new SVGElement();
6002 function SVGGlyphElement() /*:
6005 SVGElement.apply(this);
6008 SVGGlyphElement.constructor = SVGElement;
6009 SVGGlyphElement.prototype = new SVGElement();
6011 function SVGMissingGlyphElement() /*:
6014 SVGElement.apply(this);
6017 SVGMissingGlyphElement.constructor = SVGElement;
6018 SVGMissingGlyphElement.prototype = new SVGElement();
6020 function SVGHKernElement() {
6021 SVGElement.apply(this);
6024 SVGHKernElement.constructor = SVGElement;
6025 SVGHKernElement.prototype = new SVGElement();
6027 function SVGVKernElement() {
6028 SVGElement.apply(this);
6031 SVGVKernElement.constructor = SVGElement;
6032 SVGVKernElement.prototype = new SVGElement();
6034 function SVGFontFaceElement() {
6035 SVGElement.apply(this);
6036 /*boolean(or number)*/ this._isLinked = 0;
6037 this.addEventListener("DOMNodeInserted", function(evt){
6038 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6039 if (evt.target.localName === "font-face-uri") { //外部リンクがあれば
6040 evt.currentTarget._isLinked = 1;
6047 SVGFontFaceElement.constructor = SVGElement;
6048 SVGFontFaceElement.prototype = new SVGElement();
6050 function SVGFontFaceSrcElement() {
6051 SVGElement.apply(this);
6054 SVGFontFaceSrcElement.constructor = SVGElement;
6055 SVGFontFaceSrcElement.prototype = new SVGElement();
6057 function SVGFontFaceUriElement() {
6058 SVGElement.apply(this);
6059 this.addEventListener("DOMNodeInserted", function(evt){
6060 if (evt.eventPhase === /*Event.BUBBLING_PHASE*/ 3) {
6063 evt.target.ownerDocument.documentElement._svgload_limited--
6064 evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed");
6066 this.addEventListener("S_Load", function(evt){
6067 var tar = evt.target, tpp = tar.parentNode.parentNode.parentNode;
6068 if (tpp.localName === "defs") {
6069 tpp = tar.parentNode.parentNode; //tppをfont-face要素としておく
6071 tar._instance._isExternal = 1;
6072 tpp.parentNode.appendChild(tar._instance);
6073 evt = tar = tpp = void 0;
6075 SVGURIReference.apply(this);
6078 SVGFontFaceUriElement.constructor = SVGElement;
6079 SVGFontFaceUriElement.prototype = new SVGElement();
6081 function SVGFontFaceFormatElement() {
6082 SVGElement.apply(this);
6085 SVGFontFaceFormatElement.constructor = SVGElement;
6086 SVGFontFaceFormatElement.prototype = new SVGElement();
6088 function SVGFontFaceNameElement() {
6089 SVGElement.apply(this);
6092 SVGFontFaceNameElement.constructor = SVGElement;
6093 SVGFontFaceNameElement.prototype = new SVGElement();
6095 function SVGDefinitionSrcElement() {
6096 SVGElement.apply(this);
6099 SVGDefinitionSrcElement.constructor = SVGElement;
6100 SVGDefinitionSrcElement.prototype = new SVGElement();
6102 function SVGMetadataElement() {
6103 SVGElement.apply(this);
6106 SVGMetadataElement.constructor = SVGElement;
6107 SVGMetadataElement.prototype = new SVGElement();
6109 function SVGForeignObjectElement() /*:
6113 SVGExternalResourcesRequired,
6116 events::EventTarget*/ {
6117 SVGElement.apply(this);
6118 var sl = SVGAnimatedLength;
6119 /*readonly SVGAnimatedLength*/ this.x = new sl();
6120 /*readonly SVGAnimatedLength*/ this.y = new sl();
6121 /*readonly SVGAnimatedLength*/ this.width = new sl();
6122 /*readonly SVGAnimatedLength*/ this.height = new sl();
6126 SVGForeignObjectElement.constructor = SVGElement;
6127 SVGForeignObjectElement.prototype = new SVGElement();
6130 /*SVGの要素マッピング(DOMでは定められていないが、必須)
6131 *本来であれば、SVGDocumentのcreateElementNSメソッドを上書きすることが望ましいが、
6132 *SIEでは軽量化のために、マッピングを用いた
6134 DOMImplementation["http://www.w3.org/2000/svg"] = {
6135 Document: SVGDocument,
6138 path: NAIBU.SVGPathElement,
6139 title: SVGTitleElement,
6140 desc: SVGDescElement,
6141 defs: SVGDefsElement,
6142 linearGradient: SVGLinearGradientElement,
6143 radialGradient: SVGRadialGradientElement,
6144 stop: SVGStopElement,
6145 rect: SVGRectElement,
6146 circle: SVGCircleElement,
6147 ellipse: SVGEllipseElement,
6148 polyline: SVGPolylineElement,
6149 polygon: SVGPolygonElement,
6150 text: SVGTextElement,
6151 tspan: SVGTSpanElement,
6152 image: SVGImageElement,
6153 line: SVGLineElement,
6155 altGlyphDef: SVGAltGlyphDefElement,
6156 altGlyph: SVGAltGlyphElement,
6157 altGlyphItem: SVGAltGlyphItemElement,
6158 animateColor: SVGAnimateColorElement,
6159 animate: SVGAnimateElement,
6160 animateMotion: SVGAnimateMotionElement,
6161 animateTransform:SVGAnimateTransformElement,
6162 clipPath: SVGClipPathElement,
6163 colorProfile: SVGColorProfileElement,
6164 cursor: SVGCursorElement,
6165 definitionSrc: SVGDefinitionSrcElement,
6166 feBlend: SVGFEBlendElement,
6167 feGaussianBlur: SVGFEGaussianBlurElement,
6168 filter: SVGFilterElement,
6169 font: SVGFontElement,
6170 "font-face": SVGFontFaceElement,
6171 "font-face-format":SVGFontFaceFormatElement,
6172 "font-face-name":SVGFontFaceNameElement,
6173 "font-face-src": SVGFontFaceSrcElement,
6174 "font-face-uri": SVGFontFaceUriElement,
6175 foreignObject: SVGForeignObjectElement,
6176 glyph: SVGGlyphElement,
6177 glyphRef: SVGGlyphRefElement,
6178 hkern: SVGHKernElement,
6179 marker: SVGMarkerElement,
6180 mask: SVGMaskElement,
6181 metadata: SVGMetadataElement,
6182 missingGlyph: SVGMissingGlyphElement,
6183 mpath: SVGMPathElement,
6184 script: SVGScriptElement,
6186 style: SVGStyleElement,
6187 "switch": SVGSwitchElement,
6188 textPath: SVGTextPathElement,
6189 tref: SVGTRefElement,
6191 view: SVGViewElement,
6192 vkern: SVGVKernElement,
6193 pattern: SVGPatternElement
6196 NAIBU._fontSearchURI = function(evt){
6197 var doc = evt.target.ownerDocument;
6198 var tsrc = doc.getElementsByTagNameNS("http://www.w3.org/2000/svg", "font-face-uri");
6199 for (var i=0;i<tsrc.length;++i) {
6200 var src = tsrc[i].getAttributeNS("http://www.w3.org/1999/xlink", "href"),
6201 ids = src.split(":")[1],
6202 xmlhttp = NAIBU.xmlhttp;
6203 xmlhttp.open("GET", src.replace(/#.+$/, ""), true);
6204 xmlhttp.setRequestHeader("X-Requested-With", "XMLHttpRequest");
6205 xmlhttp.onreadystatechange = function() {
6206 if ((xmlhttp.readyState === 4) && (xmlhttp.status === 200)) {
6207 var doce = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml");
6208 NAIBU._font({document:doce, docu:doc, id:ids});
6209 xmlhttp = doc = doce = void 0;
6215 /*_font関数は、SVGFontで使う*/
6216 NAIBU._font = function (data) {
6217 var doc = data.document, svgns = "http://www.w3.org/2000/svg";
6218 //getElementByIdは使えないので注意(DOMParserを使った場合、DTDでの指定が必要)
6219 var font = doc.getElementsByTagNameNS(svgns, "font").item(0);
6220 var familyName = font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "font-family");
6221 if (familyName && (font.getAttributeNS(null, "id") === data.id)) {
6222 var textElements = data.docu.getElementsByTagNameNS(svgns, "text");
6223 for (var i=0,tli=textElements.length;i<tli;++i) {
6224 var ti = textElements[i], style = data.docu.defaultView.getComputedStyle(ti, '');
6225 if (style.getPropertyValue("font-family", null).indexOf(familyName) > -1) {
6226 NAIBU._noie_createFont(ti, font, false);
6230 doc = data = void 0;
6232 NAIBU._noie_createFont = function(/*Element*/ ti, /*Element*/ font, /*boolean*/ isMSIE) {
6233 var style = ti.ownerDocument.defaultView.getComputedStyle(ti, ''),
6234 svgns = "http://www.w3.org/2000/svg",
6235 //isTategakiは縦書きならば真
6236 isTategaki = ti.getAttributeNS(null, "writing-mode") || ti.parentNode.getAttributeNS(null, "writing-mode"),
6237 horizOrVert = isTategaki ? "vert-adv-y" : "horiz-adv-x",
6238 node = ti.firstChild, data, glyphs = font.getElementsByTagNameNS(svgns, "glyph"),
6239 em = parseFloat(font.getElementsByTagNameNS(svgns, "font-face").item(0).getAttributeNS(null, "units-per-em") || 1000),
6240 advX = parseFloat( (font.getAttributeNS(null, horizOrVert) || em) ), //字幅の設定
6241 dx = parseFloat(ti.getAttributeNS(null, "x") || 0),
6242 dy = parseFloat(ti.getAttributeNS(null, "y") || 0),
6243 fontSize = parseFloat(style.getPropertyValue("font-size")),
6245 ds = false, npdlist = ["fill",
6251 "stroke-miterlimit",
6256 if (/a/[-1] === 'a') { //Firefoxならば
6258 } else if (isMSIE || isTategaki) {
6267 if (data !== void 0) { //dataがある場合
6268 var advanceX = [], glyphData = [];
6269 for (var i=0,gli=glyphs.length;i<gli;++i) {
6270 var glyph = glyphs[i], unicode = glyph.getAttributeNS(null, "unicode") || "なし"; //unicode属性に指定がない場合、処理させないようにする
6271 var orientation = glyph.getAttributeNS(null, "orientation"), isVert = true, isOrientationAttribute = true;
6273 if (orientation === "h") {
6277 isOrientationAttribute = false;
6279 if ( (isTategaki && isVert) || !(isTategaki || isVert) || !isOrientationAttribute){
6280 //indexは該当する文字が何番目にあるかの数字
6281 var index = data.indexOf(unicode);
6282 while (index > -1) {
6283 advanceX[index] = parseFloat(glyph.getAttributeNS(null, horizOrVert) || advX); //字幅を収納
6284 glyphData[index] = glyph.getAttributeNS(null, "d");
6285 index = data.indexOf(unicode, index+1);
6289 for (var i=0,adv=0;i<data.length;++i) {
6290 if (advanceX[i] !== void 0) { //配列に含まれていれば
6291 var path = ti.ownerDocument.createElementNS(svgns, "path");
6292 //advance、すなわち字幅の長さ分、ずらしていく
6293 var matrix = ti.ownerDocument.documentElement.createSVGMatrix();
6296 for (var j=0;j<npdlist.length;++j){
6297 var nj = npdlist[j],
6298 tg = ti.getAttributeNS(null, nj) || style.getPropertyValue(nj);
6299 if (nj === "stroke-width") {
6300 tg = style.getPropertyCSSValue(nj).getFloatValue(1) / fe;
6304 path.setAttributeNS(null, nj, tg);
6308 var y= dy + adv*fe, x = dx;
6309 if ("、。".indexOf(data.charAt(i)) > -1) { //句読点の場合
6310 var fms = fontSize / Math.SQRT2;
6318 matrix.e = dx + adv*fe;
6321 path.setAttributeNS(null, "transform", "matrix(" +matrix.a+ "," +matrix.b+ "," +matrix.c+ "," +matrix.d+ "," +matrix.e+ "," +matrix.f+ ")");
6322 path.setAttributeNS(null, "d", glyphData[i]);
6323 ti.parentNode.insertBefore(path, ti);
6328 adv = advanceX = glyphData = void 0;
6329 } else if ("tspan|a".indexOf(node.localName) > -1){
6330 NAIBU._noie_createFont(node, font, isMSIE);
6332 node = node.nextSibling;
6335 var style = ti.ownerDocument.getOverrideStyle(ti, null);
6336 style.setProperty("visibility", "hidden");
6339 ti.setAttributeNS(null, "opacity", "0");
6342 data = isTategaki = horizOrVert = em = advX = dx = dy = fontSize = style = svgns = node = void 0;
6345 /*以下は、getComputedStyleメソッドで使うために、CSS2Propertiesの_listプロパティに、
6346 *CSSprimitiveValueのリストを収納している。なお、その際に、writingModeなどはwriting-modeに変更している
6349 var s = new CSSStyleDeclaration(),
6355 for (var i in CSS2Properties) {
6356 if(CSS2Properties.hasOwnProperty(i)) {
6357 t = i.replace(regAZ, "-");
6359 u = "-" +RegExp.$1.toLowerCase();
6363 t = t.replace(regm, u);
6364 s.setProperty(t, CSS2Properties[i]);
6365 slis[t] = slis[n]; //この処理はCSSモジュールのgetComputedStyleメソッドのため
6366 slis[n]._isDefault = 1;
6372 slis._fontSize = 12;
6373 CSS2Properties._list = slis;
6374 Document.prototype.defaultView._defaultCSS = slis;
6375 s = n = regAZ = regm = slis =null;
6378 NAIBU.addEvent = function(evt,lis){
6379 if (window.addEventListener) {
6380 window.addEventListener(evt, lis, false);
6381 } else if (window.attachEvent) {
6382 window.attachEvent('on'+evt, lis);
6384 window['on'+evt] = lis;
6392 function unsvgtovml() {
6394 if ("stop" in NAIBU) {
6395 clearInterval(NAIBU.stop);
6397 window.onscroll = NAIBU.emptyFunction;
6398 window.detachEvent("onload", NAIBU._main);
6400 Element = SVGElement = Attr = NamedNodeMap = CSS2Properties = CSSValue = CSSPrimitiveValue = NAIBU.xmlhttp = Node = Event = NAIBU = stlog = STLog = SVGColor = SVGPaint = void 0;
6401 Array = ActiveXObject = void 0;
6407 NAIBU._main = (function() {
6408 stlog = new STLog(true);
6409 var xmlhttp, //XMLHttpオブジェクトを生成
6410 _doc = document; //documentのエイリアスを作成
6412 if (XMLHttpRequest) {
6415 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
6419 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
6426 xmlhttp = new XMLHttpRequest();
6431 NAIBU.xmlhttp = xmlhttp;
6433 if (("namespaces" in _doc) && !_doc.namespaces["v"]) {
6435 NAIBU.doc = new ActiveXObject("MSXML2.DomDocument");
6440 _doc.namespaces.add("v","urn:schemas-microsoft-com:vml");
6441 _doc.namespaces.add("o","urn:schemas-microsoft-com:office:office");
6442 var st = _doc.createStyleSheet();
6443 var vmlUrl = "behavior: url(#default#VML);display: inline-block;} "; //inline-blockはIEのバグ対策
6444 st.cssText = "v\\:rect{" +vmlUrl+ "v\\:image{" +vmlUrl+ "v\\:fill{" +vmlUrl+ "v\\:stroke{" +vmlUrl+ "o\\:opacity2{" +vmlUrl
6445 + "dn\\:defs{display:none}"
6446 + "v\\:group{text-indent:0px;position:relative;width:100%;height:100%;" +vmlUrl
6447 + "v\\:shape{width:100%;height:100%;" +vmlUrl;
6449 var ary = _doc.getElementsByTagName("script");
6450 //全script要素をチェックして、type属性がimage/svg+xmlならば、中身をSVGとして処理する
6451 for (var i=0; ary[i]; ++i) {
6454 if (ai.type === "image/svg+xml") {
6456 if (sieb_s && ait.match(/<svg/)) {
6458 ait = ait.replace(/<.+?>/g, "");
6460 ait = ait.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&/g, "&");
6463 var gsd = new GetSVGDocument(ai);
6467 responseText : ait.replace(/\shref=/g, " target='_top' xlink:href=")
6471 var base = location.href.replace(/\/[^\/]+?$/,"/"); //URIの最後尾にあるファイル名は消す。例: /n/sie.js -> /n/
6472 ait = ait.replace(/\shref=(['"a-z]+?):\/\//g, " target='_top' xlink:href=$1://").replace(/\shref=(.)/g, " target='_top' xlink:href=$1"+base);
6473 var s = NAIBU.textToSVG(ait,ai.getAttribute("width"),ai.getAttribute("height"));
6474 ai.parentNode.insertBefore(s,ai);
6482 if (xmlhttp && NAIBU.isMSIE) {
6483 if (!!_doc.createElementNS && !!_doc.createElementNS( "http://www.w3.org/2000/svg", "svg").createSVGRect) { //IE9ならば
6485 var ob = _doc.getElementsByTagName("object"),
6486 em = _doc.getElementsByTagName("embed"),
6488 _search = function(_ob) {
6490 s || (s = []); //NAIBU._searchで呼ばれたときに必要
6491 _doc || (_doc = document);
6492 for (var i=0;_ob[i];++i) {
6494 s[s.length] = new GetSVGDocument(obi);
6495 ifr = _doc.createElement("iframe");
6496 ifr.style.background = "black";
6497 n = obi.getAttribute("width");
6498 n && ifr.setAttribute("width", n);
6499 n = obi.getAttribute("height");
6500 n && ifr.setAttribute("height", n);
6501 ifr.marginWidth = ifr.marginHeight = "0px"; //このマージン設定がないと、全体がずれてしまう
6502 ifr.scrolling = "no";
6503 ifr.frameBorder = "0";
6504 /*iframe要素を使って、描画のプロセスを分離する
6505 *したがって、_docはdocumentとは別のオブジェクトとなる
6507 obi.parentNode.insertBefore(ifr, obi);
6509 i = obi = ifr = _ob = void 0;
6510 return s[s.length-1];
6514 NAIBU._search = _search; //a要素がクリックされたときに使う関数
6515 ob = em = _search = void 0;
6516 for (var i=0;i<s.length;++i) {
6517 if (i < s.length-1) {
6522 s[0]._init(); //初期化作業を開始
6527 var ob = _doc.getElementsByTagName("object");
6528 for (var i=0;i<ob.length;++i) {
6529 if (ob[i].contentDocument) {
6530 NAIBU._fontSearchURI({target:{ownerDocument:ob[i].contentDocument}});
6531 } else if (ob[i].getSVGDocument) {
6532 ob[i].getSVGDocument()._docElement.addEventListener("SVGLoad", NAIBU._fontSearchURI, false);
6537 xmlhttp = _doc = void 0;
6539 NAIBU.addEvent("load", NAIBU._main);
6540 NAIBU.utf16 = function ( /*string*/ s) {
6543 NAIBU.unescapeUTF16 = function ( /*string*/ s) {
6544 return s.replace(/%u\w\w\w\w/g, NAIBU.utf16);
6546 //Text2SVG機能。SVGのソース(文章)をSVG画像に変換できる。
6547 NAIBU.textToSVG = function ( /*string*/ source, /*float*/ w, /*float*/ h) {
6548 /*Safari3.xでは、DOMParser方式だと、文字が表示されないバグがあるため、
6551 if (navigator.userAgent.indexOf('WebKit') > -1 || navigator.userAgent.indexOf('Safari') > -1) { //WebKit系ならば
6552 var data = 'data:image/svg+xml;charset=utf-8,' + NAIBU.unescapeUTF16(escape(source));
6553 var ob = document.createElement("object");
6554 ob.setAttribute("data",data);
6555 ob.setAttribute("width",w);
6556 ob.setAttribute("height",h);
6557 ob.setAttribute("type","image/svg+xml");
6560 var doc = (new DOMParser()).parseFromString(source, "text/xml");
6561 return (document.importNode(doc.documentElement, true));
6564 NAIBU.addEvent("unload", unsvgtovml);
6566 NAIBU.isMSIE = /*@cc_on!@*/false;