svnno****@sourc*****
svnno****@sourc*****
2010年 3月 25日 (木) 23:22:38 JST
Revision: 1753
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1753
Author: dhrname
Date: 2010-03-25 23:22:38 +0900 (Thu, 25 Mar 2010)
Log Message:
-----------
1, style属性の処理に関する変更
2, SVGColorのsetRGBColorメソッドを修正
Modified Paths:
--------------
branches/ufltima/dom/svg.js
Modified: branches/ufltima/dom/svg.js
===================================================================
--- branches/ufltima/dom/svg.js 2010-03-24 14:34:08 UTC (rev 1752)
+++ branches/ufltima/dom/svg.js 2010-03-25 14:22:38 UTC (rev 1753)
@@ -143,20 +143,6 @@
*/
/*readonly attribute SVGAnimatedTransformList*/ this.transform = new SVGAnimatedTransformList();
//描画の際、SVGStylabaleで指定しておいたプロパティの処理をする
- this.addEventListener("DOMNodeInsertedIntoDocument", function(evt) {
- var style = evt.target.style, sc = style.cssText;
- if (!!!sc._rewrite && (sc !== "")) {
- //style属性値の解析
- sc = sc.replace(/\:\s+/g, ":")
- .replace(/\s*;[^a-z\-]*/g, ";");
- var a = sc.split(";");
- for (var i=0, ali=a.length;i<ali;++i) {
- var ai = a[i], m = ai.split(":");
- style.setProperty(m[0], m[1]);
- }
- style.cssText._rewrite = 1;
- }
- }, true)
this.addEventListener("DOMAttrModified", function(evt){
if (evt.eventPhase === Event.BUBBLING_PHASE) {
return;
@@ -214,7 +200,20 @@
}
list = coma = mat = null;
} else if (name === "style") {
- tar.style.cssText = evt.newValue;
+ var sc = evt.newValue, style = tar.style;
+ style.cssText = sc;
+ if (sc !== "") {
+ //style属性値の解析
+ sc = sc.replace(/\:\s+/g, ":")
+ .replace(/\s*;[^a-z\-]*/g, ";");
+ var a = sc.split(";");
+ for (var i=0, ali=a.length;i<ali;++i) {
+ var ai = a[i], m = ai.split(":");
+ style.setProperty(m[0], m[1]);
+ ai = m = null;
+ }
+ a = sc = null;
+ }
} else if (name === "class") {
tar.className = evt.newValue;
} else if (name.indexOf("on") === 0) { //event属性ならば
@@ -523,10 +522,12 @@
rgbColor = rgbColor.replace(/[\d.]+%/g, function(s) {
return Math.round((2.55 * parseFloat(s)));
});
- } else if (rgbColor.indexOf("#") > 0) { //#を含む場合
- rgbColor = rgbColor.replace(/[\dA-F][\dA-F]/g, function(s) {
- return parseInt(s, 16);
- });
+ } else if (rgbColor.indexOf("#") === 0) { //#を含む場合
+ rgbColor = rgbColor.replace(/[\da-f][\da-f]/gi, function(s) {
+ return (parseInt(s, 16)+",");
+ })
+ .replace(/#/, "rgb(");
+ rgbColor += ")";
}
var s = rgbColor.match(/\d+/g);
this.rgbColor.red.setFloatValue(CSSPrimitiveValue.CSS_NUMBER, parseFloat(s[0]));
@@ -1996,7 +1997,7 @@
var style = tar.ownerDocument.defaultView.getComputedStyle(tar, "");
var el = tar._tar, fill = style.getPropertyCSSValue("fill"), stroke = style.getPropertyCSSValue("stroke");
if (fill.paintType === SVGPaint.SVG_PAINTTYPE_RGBCOLOR || fill.paintType === SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR) {
- var fillElement = document.createElement("v:fill");
+ var fillElement = !!this.fillElement ? this.fillElement : document.createElement("v:fill");
var isRadial = false;
var fc = fill.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER;
fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
@@ -2004,7 +2005,7 @@
if (fillOpacity < 1) {
fillElement.setAttribute("opacity", fillOpacity+"");
}
- if (!isRadial) {
+ if (!isRadial && !!!this.fillElement) {
el.appendChild(fillElement);
}
fc = isRadial = fillOpacity = null;