svnno****@sourc*****
svnno****@sourc*****
2010年 5月 25日 (火) 19:36:31 JST
Revision: 1844
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1844
Author: dhrname
Date: 2010-05-25 19:36:31 +0900 (Tue, 25 May 2010)
Log Message:
-----------
getComputedStyleメソッドにおいて、キャッシュを利かせるように改良
Modified Paths:
--------------
branches/ufltima/dom/css.js
Modified: branches/ufltima/dom/css.js
===================================================================
--- branches/ufltima/dom/css.js 2010-05-23 14:08:34 UTC (rev 1843)
+++ branches/ufltima/dom/css.js 2010-05-25 10:36:31 UTC (rev 1844)
@@ -468,6 +468,7 @@
cursor : "auto",
opacity : "1",
fillOpacity : "1",
+ strokeWidth : "1",
fillRule : "nonzero",
strokeDasharray : "none",
strokeDashoffset : "0",
@@ -475,7 +476,6 @@
strokeLinejoin : "miter",
strokeMiterlimit : "4",
strokeOpacity : "1",
- strokeWidth : "1",
writingMode : "lr-tb",
fontFamily : "inline",
fontSize : "inline",
@@ -696,18 +696,28 @@
*最近の計算値を取得する。Document.defaultViewはSafariがグローバル(window)にサポートしていないため付ける。
*/
/*interface ViewCSS : views::AbstractView {*/
-Document.prototype.defaultView = {
- /*CSSStyleDeclaration*/ getComputedStyle : function( /*Element*/ elt, /*string*/ pseudoElt) {
- var s = new CSSStyleDeclaration();
- do {
- //リストを連結することによって、カスケーディングを実現する
- s._list = s._list.concat(elt.style._list);
- s._list = s._list.concat(elt._attributeStyle._list); //プレゼンテーション属性を結びつける
- elt = elt.parentNode;
- } while (elt);
- s._list = s._list.concat(CSS2Properties._list); //デフォルト値の設定
- return s;
+Document.prototype.defaultView = new ViewCSS();
+function ViewCSS(){
+ this._cache = null;
+ this._cache_ele = null;
+ return this;
+};
+/*CSSStyleDeclaration*/ ViewCSS.prototype.getComputedStyle = function( /*Element*/ elt, /*string*/ pseudoElt) {
+ var s = new CSSStyleDeclaration();
+ //リストを連結することによって、カスケーディングを実現する
+ s._list = s._list.concat(elt.style._list);
+ s._list = s._list.concat(elt._attributeStyle._list); //プレゼンテーション属性を結びつける
+ var doc = elt.ownerDocument, pelt = elt.parentNode;
+ if (pelt) {
+ if (this._cache_ele !== pelt) { //キャッシュを更新する
+ this._cache = this.getComputedStyle(pelt, pseudoElt);
+ this._cache_ele = pelt;
+ }
+ s._list = s._list.concat(this._cache._list);
+ } else {
+ s._list = s._list.concat(CSS2Properties._list); //デフォルト値の設定
}
+ return s;
};
/*getOverrideStyleメソッド