svnno****@sourc*****
svnno****@sourc*****
2011年 3月 7日 (月) 22:41:34 JST
Revision: 2465 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2465 Author: dhrname Date: 2011-03-07 22:41:33 +0900 (Mon, 07 Mar 2011) Log Message: ----------- チケット #24492「単位の解釈が異常」を修正 Ticket Links: :----------- http://sourceforge.jp/projects/sie/tracker/detail/24492 Modified Paths: -------------- branches/07x/072/org/w3c/dom/svg.js Modified: branches/07x/072/org/w3c/dom/svg.js =================================================================== --- branches/07x/072/org/w3c/dom/svg.js 2011-03-07 11:10:55 UTC (rev 2464) +++ branches/07x/072/org/w3c/dom/svg.js 2011-03-07 13:41:33 UTC (rev 2465) @@ -522,7 +522,7 @@ n = this._fontSize; _s = "em"; } else if (unitType === SVGLength.SVG_LENGTHTYPE_EXS) { - n = this._fontSize * 0.55; + n = this._fontSize * 0.5; _s = "ex"; } else if (unitType === SVGLength.SVG_LENGTHTYPE_CM) { n = 35.43307; @@ -557,6 +557,15 @@ */ convertToSpecifiedUnits : function (/*unsigned short*/ unitType) { this.newValueSpecifiedUnits(unitType, this.valueInSpecifiedUnits); + }, + /*_emToUnitメソッド + *emやexが単位に使われていたときに、@fontSizeの値を手がかりに、新たな値へとvalueを変換させる + */ + _emToUnit : function (/*float*/ fontSize) { + if ((this.unitType === /*SVGLength.SVG_LENGTHTYPE_EMS*/ 3) || (this.unitType === 4)) { + this._fontSize = fontSize; + this.newValueSpecifiedUnits(this.unitType, this.valueInSpecifiedUnits); + } } }; function SVGAnimatedLength() { @@ -1421,14 +1430,19 @@ evt.target.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:show", "embed"); }, false); this.addEventListener("SVGLoad", function(evt){ - var tar = evt.target; + var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.x.baseVal._emToUnit(fontSize); + tar.y.baseVal._emToUnit(fontSize); + tar.width.baseVal._emToUnit(fontSize); + tar.height.baseVal._emToUnit(fontSize); tar.instanceRoot = tar.animatedInstanceRoot = tar.ownerDocument.importNode(tar._instance, true); var tgtb = tar.transform.baseVal; var trans = tar.ownerDocument.documentElement.createSVGTransform(); trans.setTranslate(tar.x.baseVal.value, tar.y.baseVal.value); tgtb.appendItem(trans); tar.appendChild(tar.instanceRoot); - evt = trans = tar = evtt = tgtb = null; + evt = trans = tar = evtt = tgtb = style = fontSize = null; }, false); SVGURIReference.apply(this); return this; @@ -1485,6 +1499,11 @@ } tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.x.baseVal._emToUnit(fontSize); + tar.y.baseVal._emToUnit(fontSize); + tar.width.baseVal._emToUnit(fontSize); + tar.height.baseVal._emToUnit(fontSize); var ts = tar._tar.style; ts.position = "absolute"; var ctm = tar.getScreenCTM(); @@ -1503,6 +1522,7 @@ ttfia.Style = 0; ttfia.Opacity = fillOpacity * 100; } + evt = tar = style = fontSize = ts = ctm = po = fillOpacity = null; }, false); evt = tar = null; }, false); @@ -1632,7 +1652,12 @@ /*以下では、VMLの要素とHTMLのCSSのプロパティを用いて、背景を *作り出す作業を行う。これは必須 */ - var backr = document.createElement("v:rect"); + var backr = document.createElement("v:rect"), style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.x.baseVal._emToUnit(fontSize); + tar.y.baseVal._emToUnit(fontSize); + tar.width.baseVal._emToUnit(fontSize); + tar.height.baseVal._emToUnit(fontSize); var w = tview.width, h = tview.height, sw = tar.width.baseVal.value, sh = tar.height.baseVal.value; backr.style.position = "absolute"; backr.style.width = w+ "px"; @@ -1691,7 +1716,7 @@ } } s.defaultView._cache = s.defaultView._cache_ele = null; - evt = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = w = h = sw = sh = null; + evt = objei = tar = tview = objw = objh = n = att = sdt = sp = dcp = backr = w = h = sw = sh = style = fontSize = null; trstyle = tpstyle = backrs = viewWidth = viewHeight = text = bfl = bft = bl = bt = backdown = backright = null; text = _parseFloat = null; /*IEのメモリリーク対策として、空関数を入力*/ @@ -3044,11 +3069,18 @@ } tnext = tpar = null; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target; + var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.x.baseVal._emToUnit(fontSize); + tar.y.baseVal._emToUnit(fontSize); + tar.width.baseVal._emToUnit(fontSize); + tar.height.baseVal._emToUnit(fontSize); var rx = tar.getAttributeNS(null, "rx"), ry = tar.getAttributeNS(null, "ry"); var x = tar.x.baseVal.value, y = tar.y.baseVal.value, xw = x + tar.width.baseVal.value, yh = y + tar.height.baseVal.value; var list; if ((rx || ry) && (rx !== "0") && (ry !== "0")) { + tar.rx.baseVal._emToUnit(fontSize); + tar.ry.baseVal._emToUnit(fontSize); var thrx = tar.rx.baseVal, thry = tar.ry.baseVal; thrx.value = rx ? thrx.value : thry.value; thry.value = ry ? thry.value : thrx.value; @@ -3092,7 +3124,7 @@ ele.coordsize = w + " " + h; NAIBU._setPaint(tar, ctm); delete tar._cacheMatrix, tar._currentStyle; - evt = tar = list = dat = ele = vi = null; + evt = tar = style = list = dat = ele = vi = fontSize = null; }, false); evt = tar = null; }, false); @@ -3138,7 +3170,11 @@ } tnext = tpar = null; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target; + var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.cx.baseVal._emToUnit(fontSize); + tar.cy.baseVal._emToUnit(fontSize); + tar.r.baseVal._emToUnit(fontSize); var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = ry = tar.r.baseVal.value; var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx; var rrx = rx * 0.55228, rry = ry * 0.55228; @@ -3168,7 +3204,7 @@ ele.coordsize = w + " " + h; NAIBU._setPaint(tar, ctm); delete tar._cacheMatrix, tar._currentStyle; - evt = tar = list = dat = ele = null; + evt = tar = list = style = fontSize = dat = ele = null; }, false); evt = tar = null; }, false); @@ -3215,7 +3251,12 @@ } tnext = tpar = null; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target; + var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.cx.baseVal._emToUnit(fontSize); + tar.cy.baseVal._emToUnit(fontSize); + tar.rx.baseVal._emToUnit(fontSize); + tar.ry.baseVal._emToUnit(fontSize); var cx = tar.cx.baseVal.value, cy = tar.cy.baseVal.value, rx = tar.rx.baseVal.value, ry = tar.ry.baseVal.value; var top = cy - ry, left = cx - rx, bottom = cy + ry, right = cx + rx; var rrx = rx * 0.55228, rry = ry * 0.55228; @@ -3245,7 +3286,7 @@ ele.coordsize = w + " " + h; NAIBU._setPaint(tar, ctm); delete tar._cacheMatrix, tar._currentStyle; - evt = ele = tar = dat = list = ctm = w = h = null; + evt = ele = tar = style = fontSize = dat = list = ctm = w = h = null; }, false); evt = tar = null; }, false); @@ -3292,7 +3333,12 @@ } tnext = tpar = null; tar.addEventListener("DOMNodeInsertedIntoDocument", function(evt) { - var tar = evt.target; + var tar = evt.target, style = tar.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + tar.x1.baseVal._emToUnit(fontSize); + tar.y1.baseVal._emToUnit(fontSize); + tar.x2.baseVal._emToUnit(fontSize); + tar.y2.baseVal._emToUnit(fontSize); //以下は、配列listそのものをCTMで座標変換していく処理 var vi = tar.ownerDocument.documentElement, ctm = tar.getScreenCTM(); var dat = "m "; @@ -3312,7 +3358,7 @@ ele.coordsize = w + " " + h; NAIBU._setPaint(tar, ctm); delete tar._cacheMatrix, tar._currentStyle; - evt = ele = tar = dat = list = ctm = vi = w = h = null; + evt = ele = tar = style = fontSize = dat = list = ctm = vi = w = h = null; }, false); evt = tar = null; }, false); @@ -4191,13 +4237,19 @@ if (!!!ele) { //まだ、path要素などが設定されていない場合 return; } + var style = grad.ownerDocument.defaultView.getComputedStyle(grad, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + grad.x1.baseVal._emToUnit(fontSize); + grad.y1.baseVal._emToUnit(fontSize); + grad.x2.baseVal._emToUnit(fontSize); + grad.y2.baseVal._emToUnit(fontSize); angle = 270 - Math.atan2(grad.y2.baseVal.value-grad.y1.baseVal.value, grad.x2.baseVal.value-grad.x1.baseVal.value) * 180 / Math.PI; if (angle >= 360) { angle -= 360; } ele.setAttribute("type", "gradient"); ele.setAttribute("angle", angle + ""); - evt = ele = grad = angle = null; + evt = ele = grad = angle = style = fontSize = null; }, false); return this; }; @@ -4224,6 +4276,13 @@ /*VMLでは、図の形状に沿って、円状のグラデーションを処理するようになっているため、 *四角だとおかしな模様が出てしまう。以下はそれを避ける処理 */ + var style = grad.ownerDocument.defaultView.getComputedStyle(tar, ""); + var fontSize = parseFloat(style.getPropertyValue("font-size")); + grad.cx.baseVal._emToUnit(fontSize); + grad.cy.baseVal._emToUnit(fontSize); + grad.r.baseVal._emToUnit(fontSize); + grad.fx.baseVal._emToUnit(fontSize); + grad.fy.baseVal._emToUnit(fontSize); var cx = grad.cx.baseVal.value, cy = grad.cy.baseVal.value; var r = grad.r.baseVal.value, rx, ry; rx = ry = r; @@ -4280,7 +4339,7 @@ background.filters[0].play(); tar._tar.parentNode.insertBefore(background, tar._tar); tar._tar.filled = "false"; - ellipse = outline = background = bstyle = circle = data = list = gt = cx = cy = r = w = h = matrix = null; + ellipse = outline = background = style = fontSize = bstyle = circle = data = list = gt = cx = cy = r = w = h = matrix = null; } else if (!ele.parentNode){ tar._tar.appendChild(ele); }