svnno****@sourc*****
svnno****@sourc*****
2009年 9月 30日 (水) 21:00:43 JST
Revision: 1301 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1301 Author: dhrname Date: 2009-09-30 21:00:43 +0900 (Wed, 30 Sep 2009) Log Message: ----------- Modified Paths: -------------- branches/DOM/org/w3c/dom/svg.js Modified: branches/DOM/org/w3c/dom/svg.js =================================================================== --- branches/DOM/org/w3c/dom/svg.js 2009-09-29 12:33:10 UTC (rev 1300) +++ branches/DOM/org/w3c/dom/svg.js 2009-09-30 12:00:43 UTC (rev 1301) @@ -1608,6 +1608,7 @@ return Math.round(2.55 * parseFloat(s)); }); } + this.cssText = rgbColor; } // raises( SVGException ); /*void*/ SVGColor.prototype.setColor =function(/*unsigned short*/ colorType, /*DOMString*/ rgbColor, /*DOMString*/ iccColor ){ @@ -1783,13 +1784,13 @@ var xlinkNS = "http://www.w3.org/xlink/1999", xmlNS = "http://www.w3.org/XML/1998/namespace"; var href = ele.getAttributeNS(xlinkNS, "xlink:href"); if (href) { //xlink:href属性が指定されたとき - this.show = ele.getAttribute(xlinkNS, "xlink:show"); + this.show = ele.getAttributeNS(xlinkNS, "xlink:show"); var base; - var egbase = ele.getAttribute(xmlNS, "xml:base"); + var egbase = ele.getAttributeNS(xmlNS, "xml:base"); if (!egbase) { var ep = ele.parentNode, b = null; while(!ep.parentNode) { - b = ep.getAttribute(xmlNS, "xml:base"); + b = ep.getAttributeNS(xmlNS, "xml:base"); if (b) { break; } @@ -1865,7 +1866,7 @@ */ function SVGSVGElement() { SVGElement.apply(this, arguments); - this.tar2 = document.createEleemnt("v:group"); + this.tarParent = document.createEleemnt("v:group"); /* SVGElement, SVGTests, SVGLangSpace, @@ -1910,17 +1911,17 @@ SVGSVGElement.constructor = SVGElement; SVGSVGElement.prototype = new SVGElement(); SVGSVGElement.prototype.read = function(/*float*/ w, /*float*/ h){ - this.tar2.style.visibility = "hidden"; this.w = w; this.h = h; this.tar = document.createElement("v:group"); - this.tar2.appendChild(this.tar); + this.tar.style.visibility = "hidden"; + this.tarParent.appendChild(this.tar); try{ this.children = []; //子要素 var sw = this.width.baseVal.value, sh = this.height.baseVal.value; this.currentView.read(); - this.currentView.set(w, h, this.transform._matrix); //this.transform._matrixを加工する - this.chset(this,tar2, this.transform._matirx, sw, sh); + this.transform._matrix = this.currentView.set(w, h, this.tarParent); //this.transform._matrixを加工する + this.chset(this,tar, this.transform._matirx, sw, sh); var backr = document.createElement("v:rect"); //背景の作成 backr.style.position = "absolute"; backr.style.width = w+ "px"; @@ -1928,25 +1929,25 @@ backr.style.zIndex = -1; backr.stroked = "false"; backr.filled = "false"; - this.tar2.appendChild(backr); + this.tarParent.appendChild(backr); this._backr = backr; } catch(n) {stlog.add(n,109);} }; -/*void*/ SVGSVGElement.prototype.forceRedraw = function(/*element*/ ob) { +/*void*/ SVGSVGElement.prototype.forceRedraw = function() { var w = this.w, h = this.h, c = this.children, ob = this.tar; var sw = this.width.baseVal.value, sh = this.height.baseVal.value; this.setObject(this.use,sw,sh); this.setObject(c,sw,sh); try { - var trstyle = this.rootElement.style; - var tpstyle = ob.style; + var trstyle = this.tar.style; + var tpstyle = this.tarParent.style; trstyle.visibility = "visible"; //以下、画像を切り取り trstyle.overflow = "hidden"; var backrs = this._backr.currentStyle; var viewWidth = w > sw ? sw : w, viewHeight = h > sh ? sh : h; //ウィンドウ枠の長さを決定する var bfl = parseFloat(backrs.left), bft = parseFloat(backrs.top); - var bl = -this.vi._tx, bt = -this.vi._ty; + var bl = -this.currentView._tx, bt = -this.currentView._ty; if (bfl !== 0 && !isNaN(bfl)) { //内部の図形にずれが生じたとき(isNaNはIE8でautoがデフォルト値のため) bl = bfl; tpstyle.left = -bl+ "px"; @@ -1959,7 +1960,7 @@ var backdown = bt + viewHeight + 1; trstyle.clip = "rect(" +bt+ "px " +backright+ "px " +backdown+ "px " +bl+ "px)"; //以下、テキストの位置を修正 - var text = this.tar2.getElementsByTagName("div"); + var text = this.tarParent.getElementsByTagName("div"); for (var i=0,textli=text.length;i<textli;++i) { var texti = text[i]; if (texti.firstChild.nodeName !== "shape") { //radialGradient用のdiv要素でないならば @@ -1981,6 +1982,7 @@ SVGSVGElement.prototype.setObject = function stvsetob( /*SVGElement*/ arr, /*float*/ sw, /*float*/ sh) { try { for (var i=0,arri=arr.length;i<arri;++i) { + arr[i].read(); arr[i].set(sw,sh); } } catch(e) {stlog.add(e,170);} @@ -2058,8 +2060,7 @@ rect.y = parseFloat(ovb[1]); rect.width = parseFloat(ovb[2]); rect.height = parseFloat(ovb[3])); - } else { - this.viewBox = null; + this.viewBox.animVal = rect; } var par = this.preserveAspectRatioString || "xMidYMid meet"; var sa = 1, mos = 0; @@ -2086,25 +2087,45 @@ break; } if (RegExp.$3 === "slice") { - mos = 2; + mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE; } else { - mos = 1; + mos = SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET; } } - this.preserveAspectRatio = new STPreserveAspectRatio(sa, mos); + var tpar = this.preserveAspectRatio; + tpar.animVal = tpar.baseVal.align = sa; + tpar.animVal = tpar.baseVal.meetOrSlice = mos; vb = par = null; +};with(SVGPreserveAspectRatio) { + // Alignment Types + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_UNKNOWN = 0; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_NONE = 1; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMINYMIN = 2; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMIDYMIN = 3; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMAXYMIN = 4; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMINYMID = 5; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMIDYMID = 6; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMAXYMID = 7; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMINYMAX = 8; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMIDYMAX = 9; + /*unsigned short*/ SVG_PRESERVEASPECTRATIO_XMAXYMAX = 10; + // Meet-or-slice Types + /*unsigned short*/ SVG_MEETORSLICE_UNKNOWN = 0; + /*unsigned short*/ SVG_MEETORSLICE_MEET = 1; + /*unsigned short*/ SVG_MEETORSLICE_SLICE = 2; }; + SVGViewSpec.prototype.set = function( /*float*/ vw, /*float*/ vh, /*element*/ ob) { var vB = this.viewBox.animVal, par = this.preserveAspectRatio.animVal; try { - if (!vB) { + if (!this.viewBoxString) { this._tx = this._ty = 0; return new SVGMatrix(1, 0, 0, 1, 0, 0); } var vbx = vB.x, vby = vB.y, vbw = vB.width, vbh = vB.height; var rw = vw / vbw, rh = vh / vbh; var xr = 1, yr = 1, tx = 0, ty = 0; - if (par.align === 1) { //none + if (par.align === SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE) { xr = rw; yr = rh; tx = -vbx * xr; @@ -2113,10 +2134,10 @@ var ax = (par.align + 1) % 3 + 1; var ay = Math.round(par.align / 3); switch (par.meetOrSlice) { - case 1: //meet + case SVGPreserveAspectRatio.SVG_MEETORSLICE_MEET: xr = yr = Math.min(rw, rh); break; - case 2: //slice + case SVGPreserveAspectRatio.SVG_MEETORSLICE_SLICE: xr = yr = Math.max(rw, rh); break; } @@ -2148,7 +2169,7 @@ this._ty = ty; ttps.marginLeft = this._tx+ "px"; ttps.marginTop = this._ty+ "px"; - var m = new Matrix(xr, 0, 0, yr, 0, 0); + var m = new SVGMatrix(xr, 0, 0, yr, 0, 0); return m; } catch(e) {stlog.add(e,1031);}}