| 1 |
if (typeof (cx) == "undefined") {
|
| 2 |
cx = {};
|
| 3 |
}
|
| 4 |
if (typeof (cx.fam) == "undefined") {
|
| 5 |
cx.fam = {};
|
| 6 |
}
|
| 7 |
if (typeof (cx.fam.suika) == "undefined") {
|
| 8 |
cx.fam.suika = {};
|
| 9 |
}
|
| 10 |
if (typeof (cx.fam.suika.y2005) == "undefined") {
|
| 11 |
cx.fam.suika.y2005 = {};
|
| 12 |
}
|
| 13 |
if (typeof (cx.fam.suika.y2005.CSS) == "undefined") {
|
| 14 |
cx.fam.suika.y2005.CSS = {};
|
| 15 |
}
|
| 16 |
if (typeof (cx.fam.suika.y2005.CSS.Value) == "undefined") {
|
| 17 |
cx.fam.suika.y2005.CSS.Value = {};
|
| 18 |
}
|
| 19 |
|
| 20 |
JSAN.require ("cx.fam.suika.y2005.Class.Inherit");
|
| 21 |
JSAN.require ("cx.fam.suika.y2005.DOM.Implementation");
|
| 22 |
|
| 23 |
/**
|
| 24 |
Interface |CSSImplementationValue|
|
| 25 |
*/
|
| 26 |
cx.fam.suika.y2005.DOM.Implementation.DOMImplementation._AddFeature
|
| 27 |
("http://suika.fam.cx/www/cx/fam/suika/y2005/CSS/Value#", "1.0", {
|
| 28 |
/**
|
| 29 |
Creates a CSS keyword identifier value.
|
| 30 |
|
| 31 |
@param namespaceURI The namespace URI of the identifier.
|
| 32 |
@param prefix The namespace prefix of the identifier, if any, or |null|.
|
| 33 |
@param localName The local name of the identifier.
|
| 34 |
*/
|
| 35 |
createCSSKeywordValueNS: function (namespaceURI, prefix, localName) {
|
| 36 |
localName = localName.toLowerCase ();
|
| 37 |
if (prefix != null) prefix = prefix.toLowerCase ();
|
| 38 |
return new cx.fam.suika.y2005.CSS.Value.IdentValue
|
| 39 |
(namespaceURI, prefix, localName);
|
| 40 |
},
|
| 41 |
|
| 42 |
/**
|
| 43 |
Creates a CSS numeral value.
|
| 44 |
|
| 45 |
@param value The floating number value.
|
| 46 |
@param namespaceURI The namespace URI of the unit, or |null| for no unit
|
| 47 |
or percentage.
|
| 48 |
@param prefix The namespace prefix of the unit, if any, or |null|.
|
| 49 |
@param localName The local name of the unit, |%| for percentage,
|
| 50 |
or |null| for no unit. Note that |namespaceURI|
|
| 51 |
and |prefix| are ignored if the |localName| is
|
| 52 |
either |%| or |null|.
|
| 53 |
*/
|
| 54 |
createCSSNumericValueNS: function (value, namespaceURI, prefix, localName) {
|
| 55 |
if (localName != null) localName = localName.toLowerCase ();
|
| 56 |
if (prefix != null) prefix = prefix.toLowerCase ();
|
| 57 |
if (namespaceURI == null && localName == null) {
|
| 58 |
return new cx.fam.suika.y2005.CSS.Value.NumericValue (value, null, null, null);
|
| 59 |
} else if (namespaceURI == null && localName == "%") {
|
| 60 |
return new cx.fam.suika.y2005.CSS.Value.NumericValue
|
| 61 |
(value, null, null, localName);
|
| 62 |
} else {
|
| 63 |
return new cx.fam.suika.y2005.CSS.Value.NumericValue
|
| 64 |
(value, namespaceURI, prefix, localName);
|
| 65 |
}
|
| 66 |
},
|
| 67 |
|
| 68 |
/**
|
| 69 |
Creates a CSS string value.
|
| 70 |
|
| 71 |
@param value The string value.
|
| 72 |
*/
|
| 73 |
createCSSStringValue: function (value) {
|
| 74 |
return new cx.fam.suika.y2005.CSS.Value.StringValue (value);
|
| 75 |
},
|
| 76 |
|
| 77 |
/**
|
| 78 |
Creates a CSS URI value.
|
| 79 |
|
| 80 |
@param value The DOM URI.
|
| 81 |
@param baseURI The base URI against which |value| is resolved,
|
| 82 |
if available, or |null|.
|
| 83 |
*/
|
| 84 |
createCSSURIValue: function (value, baseURI) {
|
| 85 |
return new cx.fam.suika.y2005.CSS.Value.URIValue (value, baseURI);
|
| 86 |
},
|
| 87 |
|
| 88 |
/**
|
| 89 |
Creates a CSS RGBA color value.
|
| 90 |
|
| 91 |
@param red The red color value.
|
| 92 |
@param green The green color value.
|
| 93 |
@param blue The blue color value.
|
| 94 |
@param alpha The alpha value.
|
| 95 |
@param isPercentage If |red|, |green|, and |blue| is represented in
|
| 96 |
percentage, |true|, or otherwise |false|.
|
| 97 |
@return The created RGBA color value, or |null| if parameters are out of range.
|
| 98 |
*/
|
| 99 |
createCSSRGBAValue: function (red, green, blue, alpha, isPercentage) {
|
| 100 |
if (isPercentage) {
|
| 101 |
if (red < 0 || red > 100 || green < 0 || green > 100 || blue < 0 || blue > 100)
|
| 102 |
return null;
|
| 103 |
} else {
|
| 104 |
if (red < 0 || red > 255 || green < 0 || green > 255 || blue < 0 || blue > 255)
|
| 105 |
return null;
|
| 106 |
}
|
| 107 |
return new cx.fam.suika.y2005.CSS.Value.RGBValue
|
| 108 |
(red, green, blue, alpha, isPercentage);
|
| 109 |
},
|
| 110 |
|
| 111 |
/**
|
| 112 |
Creates a CSS HSLA color value.
|
| 113 |
|
| 114 |
@param hue The hue value.
|
| 115 |
@param saturation The saturation value.
|
| 116 |
@param lightness The lightness value.
|
| 117 |
@param alpha The alpha value.
|
| 118 |
@return The created HSLA color value, or |null| if parameters are out of range.
|
| 119 |
*/
|
| 120 |
createCSSHSLAValue: function (hue, saturation, lightness, alpha) {
|
| 121 |
if (saturation < 0 || saturation > 100 || lightness < 0 || lightness > 100) {
|
| 122 |
return null;
|
| 123 |
}
|
| 124 |
return new cx.fam.suika.y2005.CSS.Value.HSLValue
|
| 125 |
(hue, saturation, lightness, alpha);
|
| 126 |
},
|
| 127 |
|
| 128 |
/**
|
| 129 |
Creates an empty |CSSValueList|.
|
| 130 |
*/
|
| 131 |
createCSSValueList: function () {
|
| 132 |
return new cx.fam.suika.y2005.CSS.Value.ValueList ();
|
| 133 |
}
|
| 134 |
});
|
| 135 |
|
| 136 |
/**
|
| 137 |
Escapes a string as an |IDENT|.
|
| 138 |
*/
|
| 139 |
cx.fam.suika.y2005.CSS.Value._EscapeIdent = function (s) {
|
| 140 |
return s.replace
|
| 141 |
(/([\u0000-\u002C\u002E\u002F\u003A-\u0040\u005B-\u005E\u0080\u007B-\u007F]|^[0-9]|^-$)/g,
|
| 142 |
function (c) {
|
| 143 |
if (!c.match (/^[\u0000-\u0020\u007F]/)) {
|
| 144 |
return "\\" + c;
|
| 145 |
} else {
|
| 146 |
var e = "000000"
|
| 147 |
+ c.charCodeAt (0).toString (16).toUpperCase ();
|
| 148 |
return "\\" + e.substring (e.length - 6);
|
| 149 |
}
|
| 150 |
});
|
| 151 |
};
|
| 152 |
|
| 153 |
/**
|
| 154 |
Interface |CSSValue|
|
| 155 |
|
| 156 |
A |CSSValue| object represents a value or a set of value used in
|
| 157 |
CSS style sheets.
|
| 158 |
*/
|
| 159 |
cx.fam.suika.y2005.CSS.Value.Value = function () {
|
| 160 |
};
|
| 161 |
|
| 162 |
/**
|
| 163 |
A textual representation of the value.
|
| 164 |
[DOM Level 2 CSS]
|
| 165 |
|
| 166 |
Note that namespace and base URI fixups are *not* done.
|
| 167 |
*/
|
| 168 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.getCSSText = function () {
|
| 169 |
return null;
|
| 170 |
};
|
| 171 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.setCSSText = function (newValue) {}
|
| 172 |
|
| 173 |
/**
|
| 174 |
The type of the value.
|
| 175 |
[DOM Level 2 CSS]
|
| 176 |
*/
|
| 177 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.getCSSValueType = function () {
|
| 178 |
return this.CSS_CUSTOM;
|
| 179 |
};
|
| 180 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.CSS_INHERIT = 0;
|
| 181 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.CSS_PRIMITIVE_VALUE = 1;
|
| 182 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.CSS_VALUE_LIST = 2;
|
| 183 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.CSS_CUSTOM = 3;
|
| 184 |
|
| 185 |
|
| 186 |
/**
|
| 187 |
Returns whether the type of the value matches to a type or not.
|
| 188 |
|
| 189 |
A type URI matches to the type of the value if:
|
| 190 |
- it is literally equal to the type URI of the value, or
|
| 191 |
- it is a superset of the type of the value, e.g.
|
| 192 |
the given type URI identifies <length> type and
|
| 193 |
the value is an |em|-united one.
|
| 194 |
|
| 195 |
The set of supported type URIs includes...
|
| 196 |
- <tag:manakai@suika.fam.cx,2005-11:integer>
|
| 197 |
- <tag:manakai@suika.fam.cx,2005-11:number>
|
| 198 |
- <tag:manakai@suika.fam.cx,2005-11:non-negative-integer>
|
| 199 |
- <tag:manakai@suika.fam.cx,2005-11:non-negative-number>
|
| 200 |
- <tag:manakai@suika.fam.cx,2005-11:percentage>
|
| 201 |
- <tag:manakai@suika.fam.cx,2005-11:length>
|
| 202 |
- <tag:manakai@suika.fam.cx,2005-11:relative-length>
|
| 203 |
- <tag:manakai@suika.fam.cx,2005-11:absolute-length>
|
| 204 |
- <tag:manakai@suika.fam.cx,2005-11:absolute-length-or-px>
|
| 205 |
- <tag:manakai@suika.fam.cx,2005-11:length-or-percentage>
|
| 206 |
- <tag:manakai@suika.fam.cx,2005-11:non-negative-length-or-percentage>
|
| 207 |
- <tag:manakai@suika.fam.cx,2005-11:angle>
|
| 208 |
- <tag:manakai@suika.fam.cx,2005-11:time>
|
| 209 |
- <tag:manakai@suika.fam.cx,2005-11:frequency>
|
| 210 |
- <tag:manakai@suika.fam.cx,2005-11:string>
|
| 211 |
- <tag:manakai@suika.fam.cx,2005-11:color>
|
| 212 |
Note. This URI does not match to <color> keywords.
|
| 213 |
- <tag:manakai@suika.fam.cx,2005-11:inheritance>
|
| 214 |
... as well as URIs used in |typeURI| attribute.
|
| 215 |
*/
|
| 216 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.matchTypeURI =
|
| 217 |
function (typeURI) {
|
| 218 |
return (this.getTypeURI () == typeURI);
|
| 219 |
};
|
| 220 |
|
| 221 |
/**
|
| 222 |
The URI that identifies the type of the value, that is:
|
| 223 |
- <tag:manakai@suika.fam.cx,2005-11:NUMBER> for a number, including
|
| 224 |
unitless zero.
|
| 225 |
- <tag:manakai@suika.fam.cx,2005-11:PERCENTAGE> for a percentage.
|
| 226 |
- <tag:manakai@suika.fam.cx,2005-11:DIMENSION> for a united number.
|
| 227 |
- <tag:manakai@suika.fam.cx,2005-11:STRING> for a string.
|
| 228 |
- <tag:manakai@suika.fam.cx,2005-11:IDENT> for a keyword, including |inherit|.
|
| 229 |
- <tag:manakai@suika.fam.cx,2005-11:FUNCTION> for a functional value,
|
| 230 |
including |url|.
|
| 231 |
- <tag:manakai@suika.fam.cx,2005-11:VALUE_LIST> for a value list.
|
| 232 |
- <tag:manakai@suika.fam.cx,2005-11:UNKNOWN> for an unknown value.
|
| 233 |
*/
|
| 234 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.getTypeURI = function () {
|
| 235 |
return "tag:manakai@suika.fam.cx,2005-11:CUSTOM";
|
| 236 |
};
|
| 237 |
|
| 238 |
cx.fam.suika.y2005.CSS.Value.Value.prototype.toString = function () {
|
| 239 |
return "[object CSSValue]";
|
| 240 |
};
|
| 241 |
|
| 242 |
|
| 243 |
/**
|
| 244 |
Interface |CSSPrimitiveValue|
|
| 245 |
*/
|
| 246 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue = function () {
|
| 247 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue._superclass.apply (this, []);
|
| 248 |
};
|
| 249 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.inherits
|
| 250 |
(cx.fam.suika.y2005.CSS.Value.Value);
|
| 251 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.getCSSValueType = function () {
|
| 252 |
return this.CSS_PRIMITIVE_VALUE;
|
| 253 |
};
|
| 254 |
|
| 255 |
/**
|
| 256 |
The type of primitive value.
|
| 257 |
[DOM Level 2 CSS]
|
| 258 |
*/
|
| 259 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.getPrimitiveType = function () {
|
| 260 |
return this.CSS_UNKNOWN;
|
| 261 |
};
|
| 262 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_UNKNOWN = 0;
|
| 263 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_NUMBER = 1;
|
| 264 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_PERCENTAGE = 2;
|
| 265 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_EMS = 3;
|
| 266 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_EXS = 4;
|
| 267 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_PX = 5;
|
| 268 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_CM = 6;
|
| 269 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_MM = 7;
|
| 270 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_IN = 8;
|
| 271 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_PT = 9;
|
| 272 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_PC = 10;
|
| 273 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_DEG = 11;
|
| 274 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_RAD = 12;
|
| 275 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_GRAD = 13;
|
| 276 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_MS = 14;
|
| 277 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_S = 15;
|
| 278 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_HZ = 16;
|
| 279 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_KHZ = 17;
|
| 280 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_DIMENSION = 18;
|
| 281 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_STRING = 19;
|
| 282 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_URI = 20;
|
| 283 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_IDENT = 21;
|
| 284 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_ATTR = 22;
|
| 285 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_COUNTER = 23;
|
| 286 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_RECT = 24;
|
| 287 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.CSS_RGBCOLOR = 25;
|
| 288 |
|
| 289 |
/* Not implemented: |getCounterValue|, |getFloatValue|, |getRGBColorValue|,
|
| 290 |
|getRectValue|, |getStringValue|, |setFloatValue|,
|
| 291 |
|setStringValue|, */
|
| 292 |
|
| 293 |
cx.fam.suika.y2005.CSS.Value.PrimitiveValue.prototype.toString = function () {
|
| 294 |
return "[object CSSPrimitiveValue]";
|
| 295 |
};
|
| 296 |
|
| 297 |
|
| 298 |
/**
|
| 299 |
Interface |CSSNumericValue|
|
| 300 |
*/
|
| 301 |
cx.fam.suika.y2005.CSS.Value.NumericValue = function (f, nsuri, pfx, lname) {
|
| 302 |
cx.fam.suika.y2005.CSS.Value.NumericValue._superclass.apply (this, []);
|
| 303 |
this.value = f;
|
| 304 |
this.namespaceURI = nsuri;
|
| 305 |
this.prefix = pfx;
|
| 306 |
this.localName = lname;
|
| 307 |
};
|
| 308 |
cx.fam.suika.y2005.CSS.Value.NumericValue.inherits
|
| 309 |
(cx.fam.suika.y2005.CSS.Value.PrimitiveValue);
|
| 310 |
|
| 311 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getPrimitiveType = function () {
|
| 312 |
if (this.namespaceURI == "urn:x-suika-fam-cx:css:") {
|
| 313 |
switch (this.localName) {
|
| 314 |
case "em": return this.CSS_EMS;
|
| 315 |
case "ex": return this.CSS_EXS;
|
| 316 |
case "px": return this.CSS_PX;
|
| 317 |
case "cm": return this.CSS_CM;
|
| 318 |
case "mm": return this.CSS_MM;
|
| 319 |
case "in": return this.CSS_IN;
|
| 320 |
case "pt": return this.CSS_PT;
|
| 321 |
case "pc": return this.CSS_PC;
|
| 322 |
case "deg": return this.CSS_DEG;
|
| 323 |
case "rad": return this.CSS_RAD;
|
| 324 |
case "grad": return this.CSS_GRAD;
|
| 325 |
case "ms": return this.CSS_MS;
|
| 326 |
case "s": return this.CSS_S;
|
| 327 |
case "hz": return this.CSS_HZ;
|
| 328 |
case "khz": return this.CSS_KHZ;
|
| 329 |
default: return this.CSS_DIMENSION;
|
| 330 |
}
|
| 331 |
} else if (this.namespaceURI == null && this.localName == null) {
|
| 332 |
return this.CSS_NUMBER;
|
| 333 |
} else if (this.namespaceURI == null && this.localName == "%") {
|
| 334 |
return this.CSS_PERCENTAGE;
|
| 335 |
} else {
|
| 336 |
return this.CSS_DIMENSION;
|
| 337 |
}
|
| 338 |
};
|
| 339 |
|
| 340 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getTypeURI = function () {
|
| 341 |
if (this.namespaceURI != null) {
|
| 342 |
return "tag:manakai@suika.fam.cx,2005-11:DIMENSION";
|
| 343 |
} else if (this.localName == "%") {
|
| 344 |
return "tag:manakai@suika.fam.cx,2005-11:PERCENTAGE";
|
| 345 |
} else { /* unitless */
|
| 346 |
return "tag:manakai@suika.fam.cx,2005-11:NUMBER";
|
| 347 |
}
|
| 348 |
};
|
| 349 |
|
| 350 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.matchTypeURI =
|
| 351 |
function (typeURI) {
|
| 352 |
if (this.namespaceURI != null) {
|
| 353 |
switch (this.namespaceURI + this.localName) {
|
| 354 |
case "urn:x-suika-fam-cx:css:em":
|
| 355 |
case "urn:x-suika-fam-cx:css:ex":
|
| 356 |
case "urn:x-suika-fam-cx:css:gd":
|
| 357 |
case "urn:x-suika-fam-cx:css:rem":
|
| 358 |
case "urn:x-suika-fam-cx:css:vw":
|
| 359 |
case "urn:x-suika-fam-cx:css:vh":
|
| 360 |
case "urn:x-suika-fam-cx:css:vm":
|
| 361 |
switch (typeURI) {
|
| 362 |
case "tag:manakai@suika.fam.cx,2005-11:length":
|
| 363 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 364 |
case "tag:manakai@suika.fam.cx,2005-11:relative-length":
|
| 365 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 366 |
return true;
|
| 367 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 368 |
return (this.value >= 0);
|
| 369 |
default:
|
| 370 |
return false;
|
| 371 |
}
|
| 372 |
case "urn:x-suika-fam-cx:css:px":
|
| 373 |
switch (typeURI) {
|
| 374 |
case "tag:manakai@suika.fam.cx,2005-11:length":
|
| 375 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 376 |
case "tag:manakai@suika.fam.cx,2005-11:relative-length":
|
| 377 |
case "tag:manakai@suika.fam.cx,2005-11:absolute-length-or-percentage":
|
| 378 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 379 |
return true;
|
| 380 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 381 |
return (this.value >= 0);
|
| 382 |
default:
|
| 383 |
return false;
|
| 384 |
}
|
| 385 |
case "urn:x-suika-fam-cx:css:in":
|
| 386 |
case "urn:x-suika-fam-cx:css:cm":
|
| 387 |
case "urn:x-suika-fam-cx:css:mm":
|
| 388 |
case "urn:x-suika-fam-cx:css:pt":
|
| 389 |
case "urn:x-suika-fam-cx:css:pc":
|
| 390 |
switch (typeURI) {
|
| 391 |
case "tag:manakai@suika.fam.cx,2005-11:length":
|
| 392 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 393 |
case "tag:manakai@suika.fam.cx,2005-11:absolute-length":
|
| 394 |
case "tag:manakai@suika.fam.cx,2005-11:absolute-length-or-percentage":
|
| 395 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 396 |
return true;
|
| 397 |
case "tag:manakai@suika.fam.cx,2005-11:non-negative-length-or-percentage":
|
| 398 |
return (this.value >= 0);
|
| 399 |
default:
|
| 400 |
return false;
|
| 401 |
}
|
| 402 |
case "urn:x-suika-fam-cx:css:deg":
|
| 403 |
case "urn:x-suika-fam-cx:css:grad":
|
| 404 |
case "urn:x-suika-fam-cx:css:rad":
|
| 405 |
case "urn:x-suika-fam-cx:css:turn":
|
| 406 |
switch (typeURI) {
|
| 407 |
case "tag:manakai@suika.fam.cx,2005-11:angle":
|
| 408 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 409 |
return true;
|
| 410 |
default:
|
| 411 |
return false;
|
| 412 |
}
|
| 413 |
case "urn:x-suika-fam-cx:css:ms":
|
| 414 |
case "urn:x-suika-fam-cx:css:s":
|
| 415 |
switch (typeURI) {
|
| 416 |
case "tag:manakai@suika.fam.cx,2005-11:time":
|
| 417 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 418 |
return true;
|
| 419 |
default:
|
| 420 |
return false;
|
| 421 |
}
|
| 422 |
case "urn:x-suika-fam-cx:css:hz":
|
| 423 |
case "urn:x-suika-fam-cx:css:khz":
|
| 424 |
switch (typeURI) {
|
| 425 |
case "tag:manakai@suika.fam.cx,2005-11:frequency":
|
| 426 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 427 |
return true;
|
| 428 |
default:
|
| 429 |
return false;
|
| 430 |
}
|
| 431 |
default:
|
| 432 |
switch (typeURI) {
|
| 433 |
case "tag:manakai@suika.fam.cx,2005-11:DIMENSION":
|
| 434 |
return true;
|
| 435 |
default:
|
| 436 |
return false;
|
| 437 |
}
|
| 438 |
}
|
| 439 |
} else if (this.localName == "%") {
|
| 440 |
switch (typeURI) {
|
| 441 |
case "tag:manakai@suika.fam.cx,2005-11:PERCENTAGE":
|
| 442 |
case "tag:manakai@suika.fam.cx,2005-11:percentage":
|
| 443 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 444 |
return true;
|
| 445 |
case "tag:manakai@suika.fam.cx,2005-11:non-negative-length-or-percentage":
|
| 446 |
return (this.value >= 0);
|
| 447 |
default:
|
| 448 |
return false;
|
| 449 |
}
|
| 450 |
} else { /* unitless */
|
| 451 |
switch (typeURI) {
|
| 452 |
case "tag:manakai@suika.fam.cx,2005-11:NUMBER":
|
| 453 |
case "tag:manakai@suika.fam.cx,2005-11:number":
|
| 454 |
return true;
|
| 455 |
case "tag:manakai@suika.fam.cx,2005-11:length":
|
| 456 |
case "tag:manakai@suika.fam.cx,2005-11:length-or-percentage":
|
| 457 |
case "tag:manakai@suika.fam.cx,2005-11:absolute-length":
|
| 458 |
case "tag:manakai@suika.fam.cx,2005-11:relative-length":
|
| 459 |
return (this.value == 0);
|
| 460 |
case "tag:manakai@suika.fam.cx,2005-11:integer":
|
| 461 |
return (this.value % 1 == 0);
|
| 462 |
case "tag:manakai@suika.fam.cx,2005-11:non-negative-integer":
|
| 463 |
return (this.value % 1 == 0 && this.value >= 0);
|
| 464 |
case "tag:manakai@suika.fam.cx,2005-11:non-negative-number":
|
| 465 |
case "tag:manakai@suika.fam.cx,2005-11:non-negative-length-or-percentage":
|
| 466 |
return (this.value >= 0);
|
| 467 |
default:
|
| 468 |
return false;
|
| 469 |
}
|
| 470 |
}
|
| 471 |
};
|
| 472 |
|
| 473 |
/**
|
| 474 |
The unit expanded URI, |%|, or |null| if no unit.
|
| 475 |
*/
|
| 476 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getUnitExpandedURI = function () {
|
| 477 |
if (this.localName != null) {
|
| 478 |
return this.namespaceURI + this.localName;
|
| 479 |
} else if (this.namespaceURI == null) {
|
| 480 |
return this.localName;
|
| 481 |
} else {
|
| 482 |
return null;
|
| 483 |
}
|
| 484 |
};
|
| 485 |
|
| 486 |
/**
|
| 487 |
The unit local name, or |null| if no unit.
|
| 488 |
*/
|
| 489 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getUnitLocalName = function () {
|
| 490 |
return this.localName;
|
| 491 |
};
|
| 492 |
|
| 493 |
/**
|
| 494 |
The unit name, or an empty string if no unit.
|
| 495 |
*/
|
| 496 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getUnitName = function () {
|
| 497 |
if (this.namespaceURI == null && this.localName == null) {
|
| 498 |
return "";
|
| 499 |
} else if (this.namespaceURI == "urn:x-suika-fam-cx:css:") {
|
| 500 |
return this.localName;
|
| 501 |
} else {
|
| 502 |
return "-" + this.prefix + "-" + this.localName;
|
| 503 |
}
|
| 504 |
};
|
| 505 |
|
| 506 |
/**
|
| 507 |
The unit namespace URI, or |null| if no unit.
|
| 508 |
*/
|
| 509 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getUnitNamespaceURI = function () {
|
| 510 |
return this.namespaceURI;
|
| 511 |
};
|
| 512 |
|
| 513 |
/**
|
| 514 |
The unit namespace prefix, or |null| if no prefix or no unit.
|
| 515 |
*/
|
| 516 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getUnitPrefix = function () {
|
| 517 |
return this.prefix;
|
| 518 |
};
|
| 519 |
|
| 520 |
/**
|
| 521 |
The float value.
|
| 522 |
*/
|
| 523 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getValue = function () {
|
| 524 |
return this.value;
|
| 525 |
};
|
| 526 |
|
| 527 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.getCSSText = function () {
|
| 528 |
var r = this.value.toString (10);
|
| 529 |
if (this.namespaceURI != null) {
|
| 530 |
r += cx.fam.suika.y2005.CSS.Value._EscapeIdent (this.getUnitName ());
|
| 531 |
} else if (this.localName == "%") {
|
| 532 |
r += "%";
|
| 533 |
}
|
| 534 |
return r;
|
| 535 |
};
|
| 536 |
/* Not implemented: |setCSSText| */
|
| 537 |
|
| 538 |
cx.fam.suika.y2005.CSS.Value.NumericValue.prototype.toString = function () {
|
| 539 |
return "[object CSSNumericValue]";
|
| 540 |
};
|
| 541 |
|
| 542 |
|
| 543 |
/**
|
| 544 |
Interface |CSSStringValue|
|
| 545 |
*/
|
| 546 |
cx.fam.suika.y2005.CSS.Value.StringValue = function (str) {
|
| 547 |
cx.fam.suika.y2005.CSS.Value.StringValue._superclass.apply (this, []);
|
| 548 |
this.value = str;
|
| 549 |
};
|
| 550 |
cx.fam.suika.y2005.CSS.Value.StringValue.inherits
|
| 551 |
(cx.fam.suika.y2005.CSS.Value.PrimitiveValue);
|
| 552 |
|
| 553 |
cx.fam.suika.y2005.CSS.Value.StringValue.prototype.getPrimitiveType = function () {
|
| 554 |
return this.CSS_STRING;
|
| 555 |
};
|
| 556 |
|
| 557 |
cx.fam.suika.y2005.CSS.Value.StringValue.prototype.getTypeURI = function () {
|
| 558 |
return "tag:manakai@suika.fam.cx,2005-11:STRING";
|
| 559 |
};
|
| 560 |
|
| 561 |
cx.fam.suika.y2005.CSS.Value.StringValue.prototype.matchTypeURI =
|
| 562 |
function (typeURI) {
|
| 563 |
return (typeURI.toLowerCase () == "tag:manakai@suika.fam.cx,2005-11:string");
|
| 564 |
};
|
| 565 |
|
| 566 |
/**
|
| 567 |
The string value.
|
| 568 |
*/
|
| 569 |
cx.fam.suika.y2005.CSS.Value.StringValue.prototype.getValue = function () {
|
| 570 |
return this.value;
|
| 571 |
};
|
| 572 |
|
| 573 |
cx.fam.suika.y2005.CSS.Value.StringValue.prototype.getCSSText = function () {
|
| 574 |
return '"'
|
| 575 |
+ this.value.replace (/([\u000A\u000C"\\]|\u000D\u000A)/g,
|
| 576 |
function (c) { return "\\" + c })
|
| 577 |
+ '"';
|
| 578 |
};
|
| 579 |
/* Not implemented: |setCSSText| */
|
| 580 |
|
| 581 |
cx.fam.suika.y2005.CSS.Value.StringValue.prototype.toString = function () {
|
| 582 |
return "[object CSSStringValue]";
|
| 583 |
};
|
| 584 |
|
| 585 |
|
| 586 |
/**
|
| 587 |
Interface |CSSIdentValue|
|
| 588 |
|
| 589 |
A |CSSIdentValue| represents a keyword used as a property value.
|
| 590 |
*/
|
| 591 |
cx.fam.suika.y2005.CSS.Value.IdentValue = function (nsuri, pfx, lname) {
|
| 592 |
cx.fam.suika.y2005.CSS.Value.IdentValue._superclass.apply (this, []);
|
| 593 |
this.namespaceURI = nsuri;
|
| 594 |
this.prefix = pfx;
|
| 595 |
this.localName = lname;
|
| 596 |
};
|
| 597 |
cx.fam.suika.y2005.CSS.Value.IdentValue.inherits
|
| 598 |
(cx.fam.suika.y2005.CSS.Value.PrimitiveValue);
|
| 599 |
|
| 600 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getPrimitiveType = function () {
|
| 601 |
if (this.namespaceURI + this.localName == "urn:x-suika-fam-cx:css:inherit") {
|
| 602 |
return undefined;
|
| 603 |
} else {
|
| 604 |
return this.CSS_IDENT;
|
| 605 |
}
|
| 606 |
};
|
| 607 |
|
| 608 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getTypeURI = function () {
|
| 609 |
return "tag:manakai@suika.fam.cx,2005-11:IDENT";
|
| 610 |
};
|
| 611 |
|
| 612 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.matchTypeURI =
|
| 613 |
function (typeURI) {
|
| 614 |
switch (this.namespaceURI + this.localName) {
|
| 615 |
case "urn:x-suika-fam-cx:css:inherit":
|
| 616 |
case "http://suika.fam.cx/~wakaba/archive/2005/cssc.initial":
|
| 617 |
switch (typeURI) {
|
| 618 |
case "tag:manakai@suika.fam.cx,2005-11:inheritance":
|
| 619 |
case "tag:manakai@suika.fam.cx,2005-11:IDENT":
|
| 620 |
return true;
|
| 621 |
default:
|
| 622 |
return false;
|
| 623 |
}
|
| 624 |
default:
|
| 625 |
if (typeURI == "tag:manakai@suika.fam.cx,2005-11:IDENT") {
|
| 626 |
return true;
|
| 627 |
} else {
|
| 628 |
return false;
|
| 629 |
}
|
| 630 |
}
|
| 631 |
};
|
| 632 |
|
| 633 |
/**
|
| 634 |
The expanded URI of the identifier.
|
| 635 |
*/
|
| 636 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getExpandedURI = function () {
|
| 637 |
return this.namespaceURI + this.localName;
|
| 638 |
};
|
| 639 |
|
| 640 |
/**
|
| 641 |
The local name of the identifier.
|
| 642 |
*/
|
| 643 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getLocalName = function () {
|
| 644 |
return this.localName;
|
| 645 |
};
|
| 646 |
|
| 647 |
/**
|
| 648 |
The name of the identifier.
|
| 649 |
*/
|
| 650 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getName = function () {
|
| 651 |
if (this.namespaceURI == "urn:x-suika-fam-cx:css:") {
|
| 652 |
return this.localName;
|
| 653 |
} else {
|
| 654 |
return "-" + this.prefix + "-" + this.localName;
|
| 655 |
}
|
| 656 |
};
|
| 657 |
|
| 658 |
/**
|
| 659 |
The namespace URI of the identifier.
|
| 660 |
*/
|
| 661 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getNamespaceURI = function () {
|
| 662 |
return this.namespaceURI;
|
| 663 |
};
|
| 664 |
|
| 665 |
/**
|
| 666 |
The namespace prefix of the identifier, or |null| if no prefix.
|
| 667 |
*/
|
| 668 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getPrefix = function () {
|
| 669 |
return this.prefix;
|
| 670 |
};
|
| 671 |
|
| 672 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.getCSSText = function () {
|
| 673 |
return cx.fam.suika.y2005.CSS.Value._EscapeIdent (this.getName ());
|
| 674 |
};
|
| 675 |
/* Not implemented: |setCSSText| */
|
| 676 |
|
| 677 |
cx.fam.suika.y2005.CSS.Value.IdentValue.prototype.toString = function () {
|
| 678 |
return "[object CSSIdentValue]";
|
| 679 |
};
|
| 680 |
|
| 681 |
|
| 682 |
/**
|
| 683 |
Interface |CSSFunctionValue|
|
| 684 |
*/
|
| 685 |
cx.fam.suika.y2005.CSS.Value.FunctionValue = function (nsuri, pfx, lname) {
|
| 686 |
cx.fam.suika.y2005.CSS.Value.FunctionValue._superclass.apply (this, []);
|
| 687 |
this.functionNamespaceURI = nsuri;
|
| 688 |
this.functionPrefix = pfx;
|
| 689 |
this.functionLocalName = lname;
|
| 690 |
};
|
| 691 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.inherits
|
| 692 |
(cx.fam.suika.y2005.CSS.Value.PrimitiveValue);
|
| 693 |
|
| 694 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getPrimitiveType = function () {
|
| 695 |
return this.CSS_CUSTOM;
|
| 696 |
};
|
| 697 |
|
| 698 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getTypeURI = function () {
|
| 699 |
return "tag:manakai@suika.fam.cx,2005-11:FUNCTION";
|
| 700 |
};
|
| 701 |
|
| 702 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.matchTypeURI =
|
| 703 |
function (typeURI) {
|
| 704 |
return (typeURI == "tag:manakai@suika.fam.cx,2005-11:FUNCTION");
|
| 705 |
};
|
| 706 |
|
| 707 |
/**
|
| 708 |
The function name expanded URI.
|
| 709 |
*/
|
| 710 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getFunctionExpandedURI =
|
| 711 |
function () {
|
| 712 |
return this.functionNamespaceURI + this.functionLocalName;
|
| 713 |
};
|
| 714 |
|
| 715 |
/**
|
| 716 |
The function local name.
|
| 717 |
*/
|
| 718 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getFunctionLocalName =
|
| 719 |
function () {
|
| 720 |
return this.functionLocalName;
|
| 721 |
};
|
| 722 |
|
| 723 |
/**
|
| 724 |
The function name.
|
| 725 |
*/
|
| 726 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getFunctionName = function () {
|
| 727 |
if (this.functionNamespaceURI == "urn:x-suika-fam-cx:css:") {
|
| 728 |
return this.functionLocalName;
|
| 729 |
} else {
|
| 730 |
return "-" + this.functionPrefix + "-" + this.functionLocalName;
|
| 731 |
}
|
| 732 |
};
|
| 733 |
|
| 734 |
/**
|
| 735 |
The function namespace URI.
|
| 736 |
*/
|
| 737 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getFunctionNamespaceURI =
|
| 738 |
function () {
|
| 739 |
return this.functionNamespaceURI;
|
| 740 |
};
|
| 741 |
|
| 742 |
/**
|
| 743 |
The function namespace prefix, or |null| if no prefix.
|
| 744 |
*/
|
| 745 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getFunctionPrefix =
|
| 746 |
function () {
|
| 747 |
return this.functionPrefix;
|
| 748 |
};
|
| 749 |
|
| 750 |
|
| 751 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.getCSSText = function () {
|
| 752 |
return cx.fam.suika.y2005.CSS.Value._EscapeIdent (this.getFunctionName ()) + "()";
|
| 753 |
};
|
| 754 |
/* Not implemented: |setCSSText| */
|
| 755 |
|
| 756 |
cx.fam.suika.y2005.CSS.Value.FunctionValue.prototype.toString = function () {
|
| 757 |
return "[object CSSFunctionValue]";
|
| 758 |
};
|
| 759 |
|
| 760 |
|
| 761 |
/**
|
| 762 |
Interface |CSSURIValue|
|
| 763 |
*/
|
| 764 |
cx.fam.suika.y2005.CSS.Value.URIValue = function (uriArg, baseURIArg) {
|
| 765 |
cx.fam.suika.y2005.CSS.Value.URIValue._superclass.apply
|
| 766 |
(this, ["urn:x-suika-fam-cx:css:", null, "url"]);
|
| 767 |
this.value = uriArg;
|
| 768 |
this.baseURI = baseURIArg;
|
| 769 |
};
|
| 770 |
cx.fam.suika.y2005.CSS.Value.URIValue.inherits
|
| 771 |
(cx.fam.suika.y2005.CSS.Value.FunctionValue);
|
| 772 |
|
| 773 |
cx.fam.suika.y2005.CSS.Value.URIValue.prototype.getPrimitiveType = function () {
|
| 774 |
return this.CSS_URI;
|
| 775 |
};
|
| 776 |
|
| 777 |
/* Not implemented: |absoluteURI| */
|
| 778 |
|
| 779 |
/**
|
| 780 |
The base URI, if available, or |null|.
|
| 781 |
*/
|
| 782 |
cx.fam.suika.y2005.CSS.Value.URIValue.prototype.getBaseURI = function () {
|
| 783 |
return this.baseURI;
|
| 784 |
};
|
| 785 |
|
| 786 |
/**
|
| 787 |
The DOM URI value.
|
| 788 |
*/
|
| 789 |
cx.fam.suika.y2005.CSS.Value.URIValue.prototype.getValue = function () {
|
| 790 |
return this.value;
|
| 791 |
};
|
| 792 |
|
| 793 |
|
| 794 |
cx.fam.suika.y2005.CSS.Value.URIValue.prototype.getCSSText = function () {
|
| 795 |
return 'url('
|
| 796 |
+ this.value.replace (/([\u000A\u000C"'()\\]|\u000D\u000A)/g,
|
| 797 |
function (c) { return "\\" + c })
|
| 798 |
+ ')';
|
| 799 |
};
|
| 800 |
/* Not implemented: |setCSSText| */
|
| 801 |
|
| 802 |
cx.fam.suika.y2005.CSS.Value.URIValue.prototype.toString = function () {
|
| 803 |
return "[object CSSURIValue]";
|
| 804 |
};
|
| 805 |
|
| 806 |
|
| 807 |
/**
|
| 808 |
Class |CSS.Value.RGBValue|
|
| 809 |
|
| 810 |
A |CSS.Value.RGBValue| object represents a RGB color value,
|
| 811 |
either in integer or in percentage, with optional alpha value.
|
| 812 |
*/
|
| 813 |
cx.fam.suika.y2005.CSS.Value.RGBValue = function (r, g, b, a, isPercentage) {
|
| 814 |
this.alpha = a > 1 ? 1 : a < 0 ? 0 : a;
|
| 815 |
cx.fam.suika.y2005.CSS.Value.RGBValue._superclass.apply
|
| 816 |
(this, ["urn:x-suika-fam-cx:css:", null, this.alpha == 1 ? "rgb" : "rgba"]);
|
| 817 |
this.red = r;
|
| 818 |
this.green = g;
|
| 819 |
this.blue = b;
|
| 820 |
this.isPercentage = isPercentage;
|
| 821 |
};
|
| 822 |
cx.fam.suika.y2005.CSS.Value.RGBValue.inherits
|
| 823 |
(cx.fam.suika.y2005.CSS.Value.FunctionValue);
|
| 824 |
|
| 825 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getPrimitiveType = function () {
|
| 826 |
if (this.a == 1) {
|
| 827 |
return this.CSS_RGBCOLOR;
|
| 828 |
} else {
|
| 829 |
return this.CSS_UNKNOWN;
|
| 830 |
}
|
| 831 |
};
|
| 832 |
|
| 833 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.matchTypeURI =
|
| 834 |
function (typeURI) {
|
| 835 |
switch (typeURI) {
|
| 836 |
case "tag:manakai@suika.fam.cx,2005-11:color":
|
| 837 |
case "tag:manakai@suika.fam.cx,2005-11:FUNCTION":
|
| 838 |
return true;
|
| 839 |
default:
|
| 840 |
return false;
|
| 841 |
}
|
| 842 |
};
|
| 843 |
|
| 844 |
/**
|
| 845 |
The red color value.
|
| 846 |
*/
|
| 847 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getR = function () {
|
| 848 |
return this.red;
|
| 849 |
};
|
| 850 |
|
| 851 |
/**
|
| 852 |
The green color value.
|
| 853 |
*/
|
| 854 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getG = function () {
|
| 855 |
return this.green;
|
| 856 |
};
|
| 857 |
|
| 858 |
/**
|
| 859 |
The blue color value.
|
| 860 |
*/
|
| 861 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getB = function () {
|
| 862 |
return this.blue;
|
| 863 |
};
|
| 864 |
|
| 865 |
/**
|
| 866 |
The alpha value.
|
| 867 |
*/
|
| 868 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getA = function () {
|
| 869 |
return this.blue;
|
| 870 |
};
|
| 871 |
|
| 872 |
/**
|
| 873 |
The unit of the color values. If color values are in percentage, |%|.
|
| 874 |
Otherwise, |null|.
|
| 875 |
[non-standard]
|
| 876 |
*/
|
| 877 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getUnitExpandedURI = function () {
|
| 878 |
return this.isPercentage ? "%" : null;
|
| 879 |
};
|
| 880 |
|
| 881 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getUnitLocalName = function () {
|
| 882 |
return this.isPercentage ? "%" : null;
|
| 883 |
};
|
| 884 |
|
| 885 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getUnitNamespaceURI = function () {
|
| 886 |
return null;
|
| 887 |
};
|
| 888 |
|
| 889 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getUnitPrefix = function () {
|
| 890 |
return null;
|
| 891 |
};
|
| 892 |
|
| 893 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.getCSSText = function () {
|
| 894 |
var unit = this.isPercentage ? "%" : "";
|
| 895 |
if (this.alpha == 1) {
|
| 896 |
return 'rgb('
|
| 897 |
+ this.red + unit + ", "
|
| 898 |
+ this.green + unit + ", "
|
| 899 |
+ this.blue + unit
|
| 900 |
+ ')';
|
| 901 |
} else {
|
| 902 |
return 'rgba('
|
| 903 |
+ this.red + unit + ", "
|
| 904 |
+ this.green + unit + ", "
|
| 905 |
+ this.blue + unit + ", "
|
| 906 |
+ this.alpha
|
| 907 |
+ ')';
|
| 908 |
}
|
| 909 |
};
|
| 910 |
/* Not implemented: |setCSSText| */
|
| 911 |
|
| 912 |
cx.fam.suika.y2005.CSS.Value.RGBValue.prototype.toString = function () {
|
| 913 |
return "[object CSSRGBValue]";
|
| 914 |
};
|
| 915 |
|
| 916 |
|
| 917 |
/**
|
| 918 |
Class |CSS.Value.HSLValue|
|
| 919 |
|
| 920 |
A |CSS.Value.HSLValue| object represents a HSL color with optional
|
| 921 |
alpha value.
|
| 922 |
*/
|
| 923 |
cx.fam.suika.y2005.CSS.Value.HSLValue = function (h, s, l, a) {
|
| 924 |
this.alpha = a > 1 ? 1 : a < 0 ? 0 : a;
|
| 925 |
cx.fam.suika.y2005.CSS.Value.HSLValue._superclass.apply
|
| 926 |
(this, ["urn:x-suika-fam-cx:css:", null, this.alpha == 1 ? "hsl" : "hsla"]);
|
| 927 |
this.hue = h % 360;
|
| 928 |
this.saturation = s;
|
| 929 |
this.lightness = l;
|
| 930 |
};
|
| 931 |
cx.fam.suika.y2005.CSS.Value.HSLValue.inherits
|
| 932 |
(cx.fam.suika.y2005.CSS.Value.FunctionValue);
|
| 933 |
|
| 934 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.matchTypeURI =
|
| 935 |
function (typeURI) {
|
| 936 |
switch (typeURI) {
|
| 937 |
case "tag:manakai@suika.fam.cx,2005-11:color":
|
| 938 |
case "tag:manakai@suika.fam.cx,2005-11:FUNCTION":
|
| 939 |
return true;
|
| 940 |
default:
|
| 941 |
return false;
|
| 942 |
}
|
| 943 |
};
|
| 944 |
|
| 945 |
/**
|
| 946 |
The hue value.
|
| 947 |
*/
|
| 948 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.getH = function () {
|
| 949 |
return this.hue;
|
| 950 |
};
|
| 951 |
|
| 952 |
/**
|
| 953 |
The saturation value.
|
| 954 |
*/
|
| 955 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.getS = function () {
|
| 956 |
return this.saturation;
|
| 957 |
};
|
| 958 |
|
| 959 |
/**
|
| 960 |
The lightness value.
|
| 961 |
*/
|
| 962 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.getL = function () {
|
| 963 |
return this.lightness;
|
| 964 |
};
|
| 965 |
|
| 966 |
/**
|
| 967 |
The alpha value.
|
| 968 |
*/
|
| 969 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.getA = function () {
|
| 970 |
return this.alpha;
|
| 971 |
};
|
| 972 |
|
| 973 |
/**
|
| 974 |
Returns a |CSS.Value.RGBValue| equal to the value.
|
| 975 |
[non-standard]
|
| 976 |
|
| 977 |
@return A |CSS.Value.RGBValue|.
|
| 978 |
*/
|
| 979 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.getRGBAValue = function () {
|
| 980 |
var hue2rgb = function (m1, m2, h) {
|
| 981 |
h = h < 0 ? h + 1 : h > 1 ? h - 1 : h;
|
| 982 |
if (h * 6 < 1) {
|
| 983 |
return m1 + (m2 - m1) * h * 6;
|
| 984 |
} else if (h * 2 < 1) {
|
| 985 |
return m2;
|
| 986 |
} else if (h * 3 < 2) {
|
| 987 |
return m1 + (m2 - m1) * (2/3 - h) * 6;
|
| 988 |
} else {
|
| 989 |
return m1;
|
| 990 |
}
|
| 991 |
};
|
| 992 |
var h = this.hue / 360;
|
| 993 |
var s = this.saturation * 0.01;
|
| 994 |
var l = this.lightness * 0.01;
|
| 995 |
var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
|
| 996 |
var m1 = l * 2 - m2;
|
| 997 |
return new cx.fam.suika.y2005.CSS.Value.RGBValue
|
| 998 |
(Math.floor (hue2rgb (m1, m2, h + 1/3) * 255),
|
| 999 |
Math.floor (hue2rgb (m1, m2, h ) * 255),
|
| 1000 |
Math.floor (hue2rgb (m1, m2, h - 1/3) * 255),
|
| 1001 |
this.alpha);
|
| 1002 |
};
|
| 1003 |
|
| 1004 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.getCSSText = function () {
|
| 1005 |
if (this.alpha == 1) {
|
| 1006 |
return 'hsl('
|
| 1007 |
+ this.hue + ", "
|
| 1008 |
+ this.saturation + "%, "
|
| 1009 |
+ this.lightness + "%"
|
| 1010 |
+ ')';
|
| 1011 |
} else {
|
| 1012 |
return 'hsla('
|
| 1013 |
+ this.hue + ", "
|
| 1014 |
+ this.saturation + "%, "
|
| 1015 |
+ this.lightness + "%, "
|
| 1016 |
+ this.alpha
|
| 1017 |
+ ')';
|
| 1018 |
}
|
| 1019 |
};
|
| 1020 |
/* Not implemented: |setCSSText| */
|
| 1021 |
|
| 1022 |
cx.fam.suika.y2005.CSS.Value.HSLValue.prototype.toString = function () {
|
| 1023 |
return "[object CSSHSLValue]";
|
| 1024 |
};
|
| 1025 |
|
| 1026 |
|
| 1027 |
/**
|
| 1028 |
Interface |CSSValueList|
|
| 1029 |
|
| 1030 |
A |CSSValueList| is an ordered collection of |CSSValue|s. A |CSSValueList|
|
| 1031 |
is also a |CSSValue|. It represents |none| keyword when the |length| is zero.
|
| 1032 |
*/
|
| 1033 |
cx.fam.suika.y2005.CSS.Value.ValueList = function () {
|
| 1034 |
cx.fam.suika.y2005.CSS.Value.ValueList._superclass.apply (this, []);
|
| 1035 |
this.items = [];
|
| 1036 |
this.separator = " ";
|
| 1037 |
};
|
| 1038 |
cx.fam.suika.y2005.CSS.Value.ValueList.inherits
|
| 1039 |
(cx.fam.suika.y2005.CSS.Value.Value);
|
| 1040 |
|
| 1041 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.getTypeURI = function () {
|
| 1042 |
return "tag:manakai@suika.fam.cx,2005-11:VALUE_LIST";
|
| 1043 |
};
|
| 1044 |
|
| 1045 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.matchTypeURI = function (typeURI) {
|
| 1046 |
return (typeURI == "tag:manakai@suika.fam.cx,2005-11:VALUE_LIST");
|
| 1047 |
};
|
| 1048 |
|
| 1049 |
/**
|
| 1050 |
Adds an item to the list.
|
| 1051 |
[non-standard]
|
| 1052 |
*/
|
| 1053 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.addItem = function (newItem) {
|
| 1054 |
this.items.push (newItem);
|
| 1055 |
};
|
| 1056 |
|
| 1057 |
/**
|
| 1058 |
Returns the |index|th value in the list, if any, or |null|.
|
| 1059 |
[DOM Level 2 CSS]
|
| 1060 |
*/
|
| 1061 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.item = function (index) {
|
| 1062 |
return this.items[index];
|
| 1063 |
};
|
| 1064 |
|
| 1065 |
/**
|
| 1066 |
Returns the number of values in the list.
|
| 1067 |
[DOM Level 2 CSS]
|
| 1068 |
*/
|
| 1069 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.getLength = function (index) {
|
| 1070 |
return this.items.length;
|
| 1071 |
};
|
| 1072 |
|
| 1073 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.getCSSText = function () {
|
| 1074 |
if (this.items.length == 0) {
|
| 1075 |
return "none";
|
| 1076 |
} else {
|
| 1077 |
var r = this.items[0].getCSSText ();
|
| 1078 |
for (var i = 1; i < this.items.length; i++) {
|
| 1079 |
r += this.separator + this.items[i].getCSSText ();
|
| 1080 |
}
|
| 1081 |
return r;
|
| 1082 |
}
|
| 1083 |
};
|
| 1084 |
/* Not implemented: |setCSSText| */
|
| 1085 |
|
| 1086 |
cx.fam.suika.y2005.CSS.Value.ValueList.prototype.toString = function () {
|
| 1087 |
return "[object CSSValueList]";
|
| 1088 |
};
|
| 1089 |
|
| 1090 |
/* $Date: 2005/11/09 09:55:19 $ */
|
| 1091 |
|
| 1092 |
/* ***** BEGIN LICENSE BLOCK *****
|
| 1093 |
* Copyright 2005 Wakaba <w@suika.fam.cx>. All rights reserved.
|
| 1094 |
*
|
| 1095 |
* This program is free software; you can redistribute it and/or
|
| 1096 |
* modify it under the same terms as Perl itself.
|
| 1097 |
*
|
| 1098 |
* Alternatively, the contents of this file may be used
|
| 1099 |
* under the following terms (the "MPL/GPL/LGPL"),
|
| 1100 |
* in which case the provisions of the MPL/GPL/LGPL are applicable instead
|
| 1101 |
* of those above. If you wish to allow use of your version of this file only
|
| 1102 |
* under the terms of the MPL/GPL/LGPL, and not to allow others to
|
| 1103 |
* use your version of this file under the terms of the Perl, indicate your
|
| 1104 |
* decision by deleting the provisions above and replace them with the notice
|
| 1105 |
* and other provisions required by the MPL/GPL/LGPL. If you do not delete
|
| 1106 |
* the provisions above, a recipient may use your version of this file under
|
| 1107 |
* the terms of any one of the Perl or the MPL/GPL/LGPL.
|
| 1108 |
*
|
| 1109 |
* "MPL/GPL/LGPL":
|
| 1110 |
*
|
| 1111 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
| 1112 |
*
|
| 1113 |
* The contents of this file are subject to the Mozilla Public License Version
|
| 1114 |
* 1.1 (the "License"); you may not use this file except in compliance with
|
| 1115 |
* the License. You may obtain a copy of the License at
|
| 1116 |
* <http://www.mozilla.org/MPL/>
|
| 1117 |
*
|
| 1118 |
* Software distributed under the License is distributed on an "AS IS" basis,
|
| 1119 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
| 1120 |
* for the specific language governing rights and limitations under the
|
| 1121 |
* License.
|
| 1122 |
*
|
| 1123 |
* The Original Code is BIDOM code.
|
| 1124 |
*
|
| 1125 |
* The Initial Developer of the Original Code is Wakaba.
|
| 1126 |
* Portions created by the Initial Developer are Copyright (C) 2005
|
| 1127 |
* the Initial Developer. All Rights Reserved.
|
| 1128 |
*
|
| 1129 |
* Contributor(s):
|
| 1130 |
* Wakaba <w@suika.fam.cx>
|
| 1131 |
*
|
| 1132 |
* Alternatively, the contents of this file may be used under the terms of
|
| 1133 |
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
| 1134 |
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
| 1135 |
* in which case the provisions of the GPL or the LGPL are applicable instead
|
| 1136 |
* of those above. If you wish to allow use of your version of this file only
|
| 1137 |
* under the terms of either the GPL or the LGPL, and not to allow others to
|
| 1138 |
* use your version of this file under the terms of the MPL, indicate your
|
| 1139 |
* decision by deleting the provisions above and replace them with the notice
|
| 1140 |
* and other provisions required by the LGPL or the GPL. If you do not delete
|
| 1141 |
* the provisions above, a recipient may use your version of this file under
|
| 1142 |
* the terms of any one of the MPL, the GPL or the LGPL.
|
| 1143 |
*
|
| 1144 |
* ***** END LICENSE BLOCK ***** */
|