svnno****@sourc*****
svnno****@sourc*****
2011年 2月 21日 (月) 23:24:06 JST
Revision: 2424
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2424
Author: dhrname
Date: 2011-02-21 23:24:05 +0900 (Mon, 21 Feb 2011)
Log Message:
-----------
getOverrideStyleメソッドの修正
Modified Paths:
--------------
branches/07x/071/org/w3c/dom/css.js
Modified: branches/07x/071/org/w3c/dom/css.js
===================================================================
--- branches/07x/071/org/w3c/dom/css.js 2011-02-19 12:25:55 UTC (rev 2423)
+++ branches/07x/071/org/w3c/dom/css.js 2011-02-21 14:24:05 UTC (rev 2424)
@@ -682,6 +682,9 @@
for (var i=0,pli=p.length;i<pli;++i) {
q[q.length] = p[i];
}
+ if (elt._runtimeStyle) {
+ q = elt._runtimeStyle._list.concat(q);
+ }
s._def = this._defaultCSS; //デフォルト値の設定
s._list = q;
if (!!elt.style) {
@@ -708,14 +711,16 @@
var s = new CSSStyleDeclaration(), setProp = s.setProperty; //このsetPropは関数オブジェクトではなくて、単なる関数のラベル
tar._runtimeStyle = s;
}
- var style = this.defaultView.getComputedStyle(tar, "")
s.setProperty = function(propertyName, value, priority) {
+ setProp.call(s, propertyName, value, priority);
var tar = elt, el = tar._tar, isFill = isStroke = false;
+ delete tar._currentStyle;
if ((tar.localName === "g") || (tar.localName === "a")) {
var sl = tar.getElementsByTagNameNS("http://www.w3.org/2000/svg", "*");
if (sl) {
for (var i=0,sli=sl.length;i<sli;++i) {
var di = sl[i];
+ delete di._currentStyle;
NAIBU._setPaint(di, di.getScreenCTM());
di = null;
}
@@ -724,146 +729,10 @@
el = null;
}
if (!el) {
- setProp.call(s, propertyName, value, priority);
return;
}
- if (!!!tar._fillElement) {
- tar._fillElement = document.createElement("v:fill"); //キャッシュを作る
- } else {
- var tgebtfill = el.getElementsByTagName("fill");
- if (tgebtfill.length > 0) {
- /*あらかじめ消しおかないと、効果が出ない*/
- el.removeChild(tgebtfill[0]);
- }
- tgebtfill = null;
- isFill = true;
- }
- if (!!!tar._strokeElement) {
- tar._strokeElement = document.createElement("v:stroke");
- } else {
- var tgebtstroke = el.getElementsByTagName("stroke")
- if (tgebtstroke.length > 0) {
- el.removeChild(tgebtstroke[0]);
- }
- tgebtstroke = null;
- isStroke = true;
- }
- var fillElement = tar._fillElement, strokeElement = tar._strokeElement;
- setProp.call(s, propertyName, value, priority);
- if (propertyName === "fill-opacity") {
- var fillOpacity = parseFloat(value) * style._list._opacity; //opacityを掛け合わせる
- if (fillOpacity < 1) {
- fillElement.setAttribute("opacity", fillOpacity+"");
- isFill = true;
- }
- } else if (propertyName === "opacity") {
- var fillOpacity = parseFloat(style.getPropertyValue("fill-opacity")) * parseFloat(value); //opacityを掛け合わせる
- if (fillOpacity < 1) {
- fillElement.setAttribute("opacity", fillOpacity+"");
- isFill = true;
- }
- var strokeOpacity = parseFloat(style.getPropertyValue("stroke-opacity")) * parseFloat(value);
- if (strokeOpacity < 1) {
- strokeElement.setAttribute("opacity", strokeOpacity+"");
- isStroke = true;
- }
- fillOpacity = strokeOpacity = null;
- } else if (propertyName === "fill") {
- var fill = s.getPropertyCSSValue("fill");
- if (value.indexOf("#") > -1) {
- /*以下では、Gradation関連の要素に、イベントを渡すことで、
- *この要素の、グラデーション描画を行う
- */
- var tod = tar.ownerDocument, t = tod.getElementById(fill.uri);
- if (t) {
- var evtt = tod.createEvent("MutationEvents");
- evtt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null);
- evtt._tar = tar._fillElement;
- evtt._style = style, evtt._ttar = tar;
- t.dispatchEvent(evtt);
- if (t.localName !== "radialGradient" && !!!tar._fillElement) {
- el.appendChild(evtt._tar);
- tar._fillElement = evtt._tar; //キャッシュを作る
- }
- isFill = true;
- t = evtt = null;
- }
- tod = null;
- } else if (value === "none") {
- tar.removeChild(tar._fillElment);
- el.filled = "false";
- } else {
- var fc = fill.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER;
- fillElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
- isFill = true;
- }
- } else if (propertyName === "stroke") {
- var stroke = style.getPropertyCSSValue("stroke");
- if (value === "none") {
- tar.removeChild(tar._strokeElment);
- el.stroked = "false";
- } else if (!stroke.uri) {
- var fc = stroke.rgbColor, num = CSSPrimitiveValue.CSS_NUMBER;
- strokeElement.setAttribute("color", "rgb(" +fc.red.getFloatValue(num)+ "," +fc.green.getFloatValue(num)+ "," +fc.blue.getFloatValue(num)+ ")");
- isStroke = true;
- }
- } else if (propertyName === "stroke-opacity") {
- var strokeOpacity = parseFloat(value) * parseFloat(style.getPropertyValue("opacity")); //opacityを掛け合わせる
- if (strokeOpacity < 1) {
- strokeElement.setAttribute("opacity", strokeOpacity);
- isStroke = true;
- }
- fc = num = strokeOpacity = null;
- } else if (propertyName === "stroke-width") {
- var sgsw = s.getPropertyCSSValue("stroke-width"), tod = tar.ownerDocument, w = tod.documentElement.viewport.width, h = tod.documentElement.viewport.height;
- sgsw._percent = Math.sqrt((w*w + h*h) / 2);
- var swx = sgsw.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) * Math.sqrt(Math.abs(tar.getScreenCTM()._determinant()));
- strokeElement.setAttribute("weight", swx + "px");
- isStroke = true;
- sgsw = w = h = null;
- } else if (propertyName === "stroke-miterlimit") {
- strokeElement.setAttribute("miterlimit", value);
- isStroke = true;
- } else if (propertyName === "stroke-linejoin") {
- strokeElement.setAttribute("joinstyle", value);
- isStroke = true;
- } else if (propertyName === "stroke-linecap") {
- if (value === "butt") {
- strokeElement.setAttribute("endcap", "flat");
- } else {
- strokeElement.setAttribute("endcap", value);
- }
- isStroke = true;
- } else if (propertyName === "stroke-dasharray") {
- var tsd = value;
- if (tsd !== "none") {
- if (tsd.indexOf(",") > 0) { //コンマ区切りの文字列の場合
- var strs = tsd.split(",");
- for (var i = 0, sli = strs.length; i < sli; ++i) {
- strs[i] = Math.ceil(parseFloat(strs[i]) / parseFloat(style.getPropertyValue("stroke-width"))); //精密ではないので注意
- }
- var strokedasharray = strs.join(" ");
- if (strs.length % 2 === 1) {
- strokedasharray += " " + strokedasharray;
- }
- }
- strokeElement.setAttribute("dashstyle", strokedasharray);
- isStroke = true;
- tsd = strs = null;
- }
- } else if ((propertyName === "cursor") && (value !== "auto") && (value !== "")) {
- el.style.cursor = value;
- } else if (propertyName === "visibility") {
- el.style.visibility = value;
- } else if (propertyName === "display") {
- el.style.display = value;
- }
- if (isFill) {
- el.appendChild(tar._fillElement);
- } else if (isStroke) {
- el.appendChild(tar._strokeElement);
- }
- el = fill = stroke = tar = value = propertyName = null;
+ NAIBU._setPaint(tar, tar.getScreenCTM());
+ el = tar = value = null;
}
return s;
};