svnno****@sourc*****
svnno****@sourc*****
2010年 12月 3日 (金) 23:33:23 JST
Revision: 2205
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2205
Author: dhrname
Date: 2010-12-03 23:33:23 +0900 (Fri, 03 Dec 2010)
Log Message:
-----------
getComputedStyleメソッドについて、キャッシュの方式を変えることで、さらなる高速化と最適化をした
Modified Paths:
--------------
branches/06x/065/org/w3c/dom/css.js
branches/06x/065/org/w3c/dom/svg.js
Modified: branches/06x/065/org/w3c/dom/css.js
===================================================================
--- branches/06x/065/org/w3c/dom/css.js 2010-12-03 14:20:53 UTC (rev 2204)
+++ branches/06x/065/org/w3c/dom/css.js 2010-12-03 14:33:23 UTC (rev 2205)
@@ -644,15 +644,16 @@
return this;
};
/*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
+ if (!!elt._currentStyle) {
+ /*キャッシュがあれば、それを返す*/
+ return (elt._currentStyle);
+ }
var s = new CSSStyleDeclaration();
+ elt._currentStyle = s;
//リストを連結することによって、カスケーディングを実現する
var pelt = elt.parentNode;
if (pelt) {
- if (this._cache_ele !== pelt) { //キャッシュを更新する
- this._cache = this.getComputedStyle(pelt, pseudoElt);
- this._cache_ele = pelt;
- }
- var p = this._cache._list;
+ var p = this.getComputedStyle(pelt, pseudoElt)._list;
} else {
var p = this._defaultCSS; //デフォルト値の設定
}
Modified: branches/06x/065/org/w3c/dom/svg.js
===================================================================
--- branches/06x/065/org/w3c/dom/svg.js 2010-12-03 14:20:53 UTC (rev 2204)
+++ branches/06x/065/org/w3c/dom/svg.js 2010-12-03 14:33:23 UTC (rev 2205)
@@ -152,6 +152,7 @@
var name = evt.attrName, tar = evt.target, _parseFloat = parseFloat;
if (!!CSS2Properties[name] || name.indexOf("-") > -1) { //スタイルシートのプロパティならば
tar._attributeStyle.setProperty(name, evt.newValue, "");
+ tar._currentStyle = null; //キャッシュは消しておく
}
if (evt.relatedNode.localName === "id") { //xml:idあるいはid属性ならば
tar.id = evt.newValue;
@@ -215,6 +216,7 @@
}
a = sc = null;
}
+ tar._currentStyle = null;
} else if (name === "class") {
tar.className = evt.newValue;
} else if (name.indexOf("on") === 0) { //event属性ならば