svnno****@sourc*****
svnno****@sourc*****
2010年 5月 31日 (月) 21:48:20 JST
Revision: 1856
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1856
Author: dhrname
Date: 2010-05-31 21:48:20 +0900 (Mon, 31 May 2010)
Log Message:
-----------
Modified Paths:
--------------
trunk/org/w3c/dom/css.js
Property Changed:
----------------
trunk/org/w3c/dom/css.js
Modified: trunk/org/w3c/dom/css.js
===================================================================
--- trunk/org/w3c/dom/css.js 2010-05-31 12:46:55 UTC (rev 1855)
+++ trunk/org/w3c/dom/css.js 2010-05-31 12:48:20 UTC (rev 1856)
@@ -184,7 +184,7 @@
*CSSの宣言ブロックを表現。削除不可。
*/
function CSSStyleDeclaration() {
- this.cssText = "";
+ this.cssText;
this.cssText._rewrite = 1;
/*long*/ this.length = 0;
/*CSSRule*/ this.parentRule = null;
@@ -302,7 +302,7 @@
};
function CSSValue() {
- this.cssText = "";
+ this.cssText;
this.cssValueType = 0;
return this;
};
@@ -314,9 +314,11 @@
function CSSPrimitiveValue() {
CSSValue.call(this, arguments);
- this.cssValueType = CSSValue.CSS_PRIMITIVE_VALUE;
- this.primitiveType = CSSPrimitiveValue.CSS_UNKNOWN;
+ this.cssValueType = 1;//CSSValue.CSS_PRIMITIVE_VALUE;
+ this.primitiveType = 0;//CSSPrimitiveValue.CSS_UNKNOWN;
this._value = 1;
+ this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
+ this._empercent = 0;
return this;
};
@@ -364,6 +366,33 @@
if (CSSPrimitiveValue.CSS_UNKNOWN >= unitType && unitType >= CSSPrimitiveValue.CSS_STRING) { //浮動小数点数単位型をサポートしないCSS単位である場合
throw new DOMException(DOMException.INVALID_ACCESS_ERR);
}
+ var n = this.cssText.match(/\D+$/), type = 0, _parseFloat = parseFloat;
+ var s = _parseFloat(this.cssText.match(/[\d\.]+/));
+ s = isNaN(s) ? 0 : s;
+ if (!n) {
+ type = SVGLength.SVG_LENGTHTYPE_NUMBER;
+ } else if (n === "%") {
+ s *= this._percent;
+ type = CSSPrimitiveValue.CSS_PERCENTAGE;
+ } else if (n === "em") {
+ s *= this._empercent;
+ type = CSSPrimitiveValue.CSS_EMS;
+ } else if (n === "ex") {
+ type = CSSPrimitiveValue.CSS_EXS;
+ } else if (n === "px") {
+ type = CSSPrimitiveValue.CSS_PX;
+ } else if (n === "cm") {
+ type = CSSPrimitiveValue.CSS_CM;
+ } else if (n === "mm") {
+ type = CSSPrimitiveValue.CSS_MM;
+ } else if (n === "in") {
+ type = CSSPrimitiveValue.CSS_IN;
+ } else if (n === "pt") {
+ type = CSSPrimitiveValue.CSS_PT;
+ } else if (n === "pc") {
+ type = CSSPrimitiveValue.CSS_PC;
+ }
+ this.setFloatValue(type, s);
return (this._value / this._n[unitType-1]);
};
/*void*/ CSSPrimitiveValue.prototype.setStringValue = function(/*short*/ stringType, /*string*/ stringValue) {
@@ -469,6 +498,7 @@
cursor : "auto",
opacity : "1",
fillOpacity : "1",
+ strokeWidth : "1",
fillRule : "nonzero",
strokeDasharray : "none",
strokeDashoffset : "0",
@@ -476,7 +506,6 @@
strokeLinejoin : "miter",
strokeMiterlimit : "4",
strokeOpacity : "1",
- strokeWidth : "1",
writingMode : "lr-tb",
fontFamily : "inline",
fontSize : "inline",
@@ -697,18 +726,29 @@
*最近の計算値を取得する。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 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); //デフォルト値の設定
}
+ s._document = elt.ownerDocument;
+ return s;
};
/*getOverrideStyleメソッド
Property changes on: trunk/org/w3c/dom/css.js
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/ufltima/dom/css.js:1621-1855