svnno****@sourc*****
svnno****@sourc*****
2011年 11月 15日 (火) 20:19:55 JST
Revision: 3092
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=3092
Author: dhrname
Date: 2011-11-15 20:19:54 +0900 (Tue, 15 Nov 2011)
Log Message:
-----------
getComputedStyleメソッドにおいて、font-sizeに%などの相対単位が使われていたときの対処
Modified Paths:
--------------
branches/08x/089/org/w3c/dom/css.js
Modified: branches/08x/089/org/w3c/dom/css.js
===================================================================
--- branches/08x/089/org/w3c/dom/css.js 2011-11-15 10:49:55 UTC (rev 3091)
+++ branches/08x/089/org/w3c/dom/css.js 2011-11-15 11:19:54 UTC (rev 3092)
@@ -338,6 +338,7 @@
tg = "_" +RegExP.$1
ti[tg] = parseFloat(value);
} else {
+ this._em = this._ex = this["_%"] = null;
this._list._fontSize = parseFloat(value);
}
}
@@ -412,6 +413,7 @@
this._value = null;
this._percent = 0; //単位に%が使われていた場合、このプロパティの数値を1%として使う
this._empercent = 0;
+ this._em = this._ex = this["_%"] = null; //emが単位の場合、getComputedStyleメソッドなどで使う
/*void*/ this.setFloatValue = function(/*short*/ unitType, /*float*/ floatValue) {
if ((/*CSSPrimitiveValue.CSS_UNKNOWN*/ 0 >= unitType) && (unitType >= /*CSSPrimitiveValue.CSS_STRING*/ 19)) { //浮動小数点数単位型をサポートしないCSS単位である場合
throw new DOMException(DOMException.INVALID_ACCESS_ERR);
@@ -712,7 +714,8 @@
s.getPropertyCSSValue = (function(elt, td, s){
return function( /*string*/ propertyName) {
var el = elt,
- css = null;
+ css = null,
+ n;
while (el && (!css || (css.cssValueType === /*CSSValue.CSS_INHERIT*/ 0))) {
if (el._runtimeStyle && el._runtimeStyle[propertyName]) {
css = el._runtimeStyle.getPropertyCSSValue(propertyName);
@@ -735,6 +738,24 @@
}
if (css && css.setRGBColor && ((css.paintType === /*SVGPaint.SVG_PAINTTYPE_CURRENTCOLOR*/ 102) || (css.colorType === /*SVGColor.SVG_COLORTYPE_CURRENTCOLOR*/ 3))) {
css.setRGBColor(s.getPropertyValue("color"));
+ } else if (css && (css._em || css._ex || css["_%"])) {
+ el = elt;
+ n = 1;
+ while (el) {
+ if (el.style._list._fontSize) {
+ n = el.style._list._fontSize;
+ break;
+ }
+ el = el.parentNode;
+ }
+ if (css._em) {
+ n *= css._em;
+ } else if (css._ex) {
+ n *= css._ex * 0.5;
+ } else if (css["_%"]) {
+ n *= css["_%"] / 100;
+ }
+ css.cssText = "font-size:" +n+ "px";
}
el = void 0;
return css;