/[suikacvs]/webroot/www/css/jsie/Node.js
Suika

Contents of /webroot/www/css/jsie/Node.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download) (as text)
Sun Dec 30 05:09:05 2007 UTC (17 years, 3 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +66 -163 lines
File MIME type: application/javascript
Partial attempt to make scripts work without JSAN

1 function Factory () { }
2
3 /**
4 Creates a CSS style sheet object.
5 [DOM Level 2 CSS]
6 */
7 Factory.prototype.createCSSStyleSheet = function (title, media) {
8 var ss = StyleSheet ();
9 if (title != null) ss._SetTitle (title);
10 //if (media != null) /* not implemented */
11 return ss;
12 };
13
14 /**
15 Creates a CSS |@import| rule object.
16
17 Note. Creating a |@import| object does not mean to load the referenced
18 style sheet.
19 @@ISSUE: Inserting the rule into a style sheet should make
20 the referenced style sheet loaded?
21
22 [non-standard]
23
24 @param href The DOM URI of the referenced style sheet.
25 @param media The media query associated to the rule.
26 If |null| is specified, then an empty media list
27 (which is equivalent to |all| by definition) is set.
28 @return The newly created |@import| rule.
29 */
30 Factory.prototype.createCSSImportRule = function (href, media) {
31 return new ImportRule (href, media);
32 };
33
34 /**
35 Creates a CSS |@charset| rule object.
36 [non-standard]
37 */
38 Factory.prototype.createCSSCharsetRule = function (charset) {
39 return new CharsetRule (charset);
40 };
41
42 /**
43 Creates a CSS |@namespace| rule object.
44
45 [non-standard]
46
47 @param prefix The namespace prefix, or |null| if it defines the
48 default namespace URI.
49 @param namespaceURI The namespace URI.
50 @return The newly created |@namespace| rule.
51 */
52 Factory.prototype.createCSSNamespaceRule = function (prefix, namespaceURI) {
53 return new NamespaceRule (prefix, namespaceURI);
54 };
55
56 /**
57 Creates a CSS rule set object.
58 [non-standard]
59 */
60 Factory.prototype.createCSSRuleSet = function (selector) {
61 return new RuleSet (selector);
62 };
63
64 /**
65 Creates a CSS property declaration object.
66 [non-standard]
67
68 @param namespaceURI The namespace URI of the property.
69 @param prefix The namespace prefix of the property, if any, or |null|.
70 @param localName The local name of the property.
71 @param value The value of the property.
72 */
73 Factory.prototype.createCSSPropertyNS = function (namespaceURI, prefix, localName, value, priority) {
74 if (priority == null) {
75 priority = this.createCSSKeywordValueNS
76 ("http://suika.fam.cx/~wakaba/archive/2005/cssc.",
77 "manakaic", "normal");
78 }
79 return new PropertyDeclaration
80 (namespaceURI, prefix, localName, value, priority);
81 };
82
83 var CSS_UNKNOWN_RULE_NODE = 0;
84 var CSS_RULE_SET_NODE = 1;
85 var CSS_AT_CHARSET_NODE = 2;
86 var CSS_AT_IMPORT_NODE = 3;
87 var CSS_AT_MEDIA_NODE = 4;
88 var CSS_AT_FONT_FACE_NODE = 5;
89 var CSS_AT_PAGE_NODE = 6;
90 var CSS_UNKNOWN_NODE = 100;
91 var CSS_STYLE_SHEET_NODE = 101;
92 var CSS_DECLARATION_BLOCK_NODE = 102;
93 var CSS_EMPTY_DECLARATION_NODE = 103;
94 var CSS_PROPERTY_DECLARATION_NODE = 104;
95 var CSS_AT_NAMESPACE_NODE = 106;
96
97 // _EscapeIdent = Value._EscapeIdent
98
99 /**
100 Interface |CSSStyleSheet|
101
102 A |CSSStyleSheet| object represents a CSS style sheet.
103 */
104 function StyleSheet () {
105 this.cssRules = new RuleList ();
106 };
107
108 StyleSheet.prototype.getCSSNodeType = function () {
109 return CSS_STYLE_SHEET_NODE;
110 };
111
112 /**
113 Appends a |CSSRule| to the list.
114 [non-standard]
115 */
116 StyleSheet.prototype.appendCSSRule = function (newRule) {
117 /* There should be |HIERARCHY_REQUEST_ERR|. */
118 newRule._SetParentStyleSheet (this);
119 newRule._SetParentRule (null);
120 return this.cssRules.v.push (newRule);
121 };
122
123 /**
124 The base URI of the style sheet. If it is not explicitly set,
125 then |href| is the base URI. If |href| is not defined neither,
126 then |null|.
127 [non-standard]
128 */
129 StyleSheet.prototype.getBaseURI = function () {
130 if (this.baseURI != null) {
131 return this.baseURI;
132 } else {
133 return this.href;
134 }
135 };
136
137 StyleSheet.prototype._SetBaseURI = function (newValue) {
138 this.baseURI = newValue;
139 };
140
141 /**
142 The list of rules, i.e. rule sets and at-rules.
143 [DOM Level 2 CSS]
144 */
145 StyleSheet.prototype.getCSSRules = function () {
146 return this.cssRules;
147 };
148
149 /**
150 The textual representation of the style sheet.
151 [non-standard]
152 */
153 StyleSheet.prototype.getCSSText = function () {
154 var r = "";
155 var lastType = CSS_UNKNOWN_RULE_NODE;
156 for (var i = 0; i < this.cssRules.v.length; i++) {
157 var rule = this.cssRules.v[i];
158 if (lastType == CSS_RULE_SET_NODE ||
159 rule.getCSSNodeType () == CSS_RULE_SET_NODE) {
160 r += "\n";
161 }
162 lastType = rule.getCSSNodeType ();
163 r += rule.getCSSText ();
164 }
165 /* TODO: Namespace fixup */
166 return r;
167 };
168
169 /**
170 Whether the style sheet is applied to the document or not.
171 [DOM Level 2 Style Sheets]
172 */
173 StyleSheet.prototype.getDisabled = function () {
174 return this.disabled;
175 };
176 StyleSheet.prototype.setDisabled = function (newValue) {
177 this.disabled = newValue;
178 };
179
180 /**
181 The URI of the style sheet document, if available, or |null|.
182 [DOM Level 2 Style Sheets]
183 */
184 StyleSheet.prototype.getHref = function () {
185 return this.href;
186 };
187 StyleSheet.prototype._SetHref = function (newValue) {
188 this.href = newValue;
189 };
190
191 /* Not implemented: |media|, |ownerNode| from DOM Level 2 Style Sheets,
192 |setCSSText| */
193
194 /**
195 Returns the namespace URI associated to a namespace prefix,
196 if any, or |null|.
197 [non-standard]
198
199 @param prefix The namespace prefix to lookup. If |null|, default
200 namespace URI, if any, is returned. Note that in CSS
201 identifiers including prefixes are case-insensitive.
202 @return The namespace URI associated with |prefix|, if any, or |null|.
203 */
204 StyleSheet.prototype.lookupNamespaceURI =
205 function (prefix) {
206 if (prefix != null) prefix = prefix.toLowerCase ();
207 var uri = null;
208 for (var i = 0; i < this.cssRules.v.length; i++) {
209 var rule = this.cssRules.v[i];
210 var ruleType = rule.getType ();
211 if (ruleType == rule.NAMESPACE_RULE) {
212 if (rule.getPrefix () == prefix) {
213 uri = rule.getNamespaceURI ();
214 }
215 /* Don't |break|, since last occurence is in effect if there is
216 more than one declarations. */
217 } else if (ruleType != rule.CHARSET_RULE &&
218 ruleType != rule.IMPORT_RULE) {
219 break;
220 }
221 }
222 return uri;
223 };
224
225 /**
226 The rule that references the style sheet, if any, or |null| otherwise.
227 [DOM Level 2 CSS]
228 */
229 StyleSheet.prototype.getOwnerRule = function () {
230 return this.ownerRule;
231 };
232 StyleSheet.prototype._SetOwnerRule = function (newValue) {
233 this.ownerRule = newValue;
234 };
235
236 /**
237 The parent style sheet, if any, or |null|.
238 [DOM Level 2 Style Sheets]
239 */
240 StyleSheet.prototype.getParentStyleSheet = function () {
241 return this.parentStyleSheet;
242 };
243 StyleSheet.prototype._SetParentStyleSheet =
244 function (newValue) {
245 this.parentStyleSheet = newValue;
246 for (var i = 0; i < this.cssRules.v.length; i++) {
247 this.cssRules.v[i]._SetParentStyleSheet (newValue);
248 }
249 };
250
251 /**
252 The title of the style sheet, if any, or |null|.
253 [DOM Level 2 Style Sheets]
254 */
255 StyleSheet.prototype.getTitle = function () {
256 return this.title;
257 };
258 StyleSheet.prototype._SetTitle =
259 function (newValue) {
260 this.title = newValue;
261 };
262
263 /**
264 The Internet media type of the style sheet.
265 [DOM Level 2 Style Sheets]
266 */
267 StyleSheet.prototype.getType = function () {
268 return "text/css";
269 };
270
271 StyleSheet.prototype.toString = function () {
272 return "[object CSSStyleSheet]";
273 };
274
275 /* Not implemented: |insertRule|, |deleteRule| from DOM Level 2 CSS */
276
277
278 /*
279 Interface |CSSRule|
280
281 A |CSSRule| represents a rule set or at-rule (i.e. a |statement|
282 in CSS source document).
283 */
284 cx.fam.suika.y2005.CSS.Node.Rule = function () {
285 cx.fam.suika.y2005.CSS.Node.Rule._superclass.apply (this, arguments);
286 };
287 cx.fam.suika.y2005.CSS.Node.Rule.inherits (cx.fam.suika.y2005.CSS.Node.Node);
288
289 /**
290 Appends a |CSSRule| to the list.
291 [non-standard]
292 */
293 cx.fam.suika.y2005.CSS.Node.Rule.prototype.appendCSSRule = function (newRule) {
294 /* There should be |HIERARCHY_REQUEST_ERR|. */
295 newRule._SetParentStyleSheet (this.parentStyleSheet);
296 newRule._SetParentRule (this);
297 return this.cssRules.v.push (newRule);
298 };
299
300 /**
301 The textual representation of the rule.
302 [DOM Level 2 CSS]
303
304 Note that namespace fix up is not done.
305 */
306 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getCSSText =
307 function () {
308 return "@" + this._EscapeIdent (this.getRuleName ()) + ";\n";
309 };
310 /* Not implemented: |setCSSText| from DOM Level 2 CSS */
311
312 /*
313 The rule that contains this rule, if any, or |null| otherwise.
314 [DOM Level 2 CSS]
315 */
316 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getParentRule = function () {
317 return this.parentRule;
318 };
319 cx.fam.suika.y2005.CSS.Node.Rule.prototype._SetParentRule = function (newValue) {
320 this.parentRule = newValue;
321 };
322
323 /*
324 The style sheet that contains the rule.
325 [DOM Level 2 CSS]
326
327 It might be |null| if the rule is not part of any style sheet
328 in this implementation.
329 */
330 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getParentStyleSheet = function () {
331 return this.parentStyleSheet;
332 };
333 cx.fam.suika.y2005.CSS.Node.Rule.prototype._SetParentStyleSheet = function (newValue) {
334 this.parentStyleSheet = newValue;
335 if (this.cssRules) {
336 for (var i = 0; i < this.cssRules.v.length; i++) {
337 this.cssRules.v[i]._SetParentStyleSheet (mewValue);
338 }
339 }
340 };
341
342 /**
343 The local name of the rule. If the rule is not an at-rule, |null|.
344 [non-standard]
345 */
346 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getRuleLocalName = function () {
347 return this.ruleLocalName;
348 };
349
350 /**
351 The qualified name of the rule. If the rule is not an at-rule, |null|.
352 [non-standard]
353 */
354 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getRuleName = function () {
355 if (this.ruleNamespaceURI == "urn:x-suika-fam-cx:css:") {
356 return this.ruleLocalName;
357 } else {
358 return "-" + this.rulePrefix + "-" + this.ruleLocalName;
359 }
360 };
361
362 /**
363 The namespace URI of the rule. If the rule is not an at-rule, |null|.
364 [non-standard]
365 */
366 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getRuleNamespaceURI = function () {
367 return this.ruleNamespaceURI;
368 };
369
370 /**
371 The namespace prefix of the rule. If the rule is not an at-rule
372 or the rule has no namespace prefix, |null|.
373 [non-standard]
374 */
375 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getRulePrefix = function () {
376 return this.rulePrefix;
377 };
378 cx.fam.suika.y2005.CSS.Node.Rule.prototype.setRulePrefix = function (newValue) {
379 this.rulePrefix = newValue;
380 };
381
382 /**
383 The type of the rule.
384 [DOM Level 2 CSS]
385 */
386 cx.fam.suika.y2005.CSS.Node.Rule.prototype.getType = function () {
387 return this.UNKNOWN_RULE;
388 };
389 cx.fam.suika.y2005.CSS.Node.Rule.prototype.UNKNOWN_RULE = 0;
390 cx.fam.suika.y2005.CSS.Node.Rule.prototype.STYLE_RULE = 1;
391 cx.fam.suika.y2005.CSS.Node.Rule.prototype.CHARSET_RULE = 2;
392 cx.fam.suika.y2005.CSS.Node.Rule.prototype.IMPORT_RULE = 3;
393 cx.fam.suika.y2005.CSS.Node.Rule.prototype.MEDIA_RULE = 4;
394 cx.fam.suika.y2005.CSS.Node.Rule.prototype.FONT_FACE_RULE = 5;
395 cx.fam.suika.y2005.CSS.Node.Rule.prototype.PAGE_RULE = 6;
396
397 /**
398 |@namespace| rule.
399 [non-standard]
400
401 Note. The |type| value of |@namespace| rules is |0|,
402 i.e. |UNKNOWN_RULE|, in Gecko.
403 */
404 cx.fam.suika.y2005.CSS.Node.Rule.prototype.NAMESPACE_RULE = 1001;
405
406 /**
407 Interface |CSSAtRule|
408 */
409 cx.fam.suika.y2005.CSS.Node.AtRule = function (namespaceURI, localName) {
410 cx.fam.suika.y2005.CSS.Node.AtRule._superclass.apply (this, []);
411 this.ruleNamespaceURI = namespaceURI;
412 this.ruleLocalName = localName.toLowerCase ();
413 };
414 cx.fam.suika.y2005.CSS.Node.AtRule.inherits (cx.fam.suika.y2005.CSS.Node.Rule);
415
416 cx.fam.suika.y2005.CSS.Node.AtRule.prototype.toString = function () {
417 return "[object CSSAtRule]";
418 };
419
420 /**
421 Interface |CSSMediaRule|
422 */
423 cx.fam.suika.y2005.CSS.Node.MediaRule = function (mq) {
424 cx.fam.suika.y2005.CSS.Node.MediaRule._superclass.apply
425 (this, ["urn:x-suika-fam-cx:css:", "media"]);
426 this.cssRules = new cx.fam.suika.y2005.CSS.RuleList ();
427 if (mq != null) {
428 this.media = mq;
429 } else {
430 /* TODO: set empty media query */
431 }
432 };
433 cx.fam.suika.y2005.CSS.Node.MediaRule.inherits (cx.fam.suika.y2005.CSS.Node.AtRule);
434 cx.fam.suika.y2005.CSS.Node.MediaRule.prototype.getCSSNodeType = function () {
435 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_AT_MEDIA_NODE;
436 };
437 cx.fam.suika.y2005.CSS.Node.MediaRule.prototype.getType = function () {
438 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.MEDIA_RULE;
439 };
440
441 /**
442 The list of rules within the |@media| block.
443 [DOM Level 2 CSS]
444 */
445 cx.fam.suika.y2005.CSS.Node.MediaRule.prototype.getCSSRules = function () {
446 return this.cssRules;
447 };
448
449
450 /**
451 The textual representation of the rule.
452 [DOM Level 2 CSS]
453
454 Note that namespace fix up is not done.
455 */
456 cx.fam.suika.y2005.CSS.Node.MediaRule.prototype.getCSSText =
457 function () {
458 var r = "@media";
459 var mq = this.media.getMediaText ();
460 if (mq.length > 0) {
461 r += " " + mq;
462 }
463 r += " {\n\n";
464 for (var i = 0; i < this.cssRules.v.length; i++) {
465 r += this.cssRules.v[i].getCSSText () + "\n";
466 }
467 r += "}\n";
468 return r;
469 };
470 /* Not implemented: |setCSSText| */
471
472 /**
473 The media query.
474 [DOM Level 2 CSS]
475 */
476 cx.fam.suika.y2005.CSS.Node.MediaRule.prototype.getMedia = function () {
477 return this.media;
478 };
479
480 /* Not implemented: |insertRule|, |deleteRule| from DOM Level 2 CSS */
481
482 cx.fam.suika.y2005.CSS.Node.MediaRule.prototype.toString = function () {
483 return "[object CSSMediaRule]";
484 };
485
486
487 /**
488 Interface |CSSFontFaceRule|
489 */
490 cx.fam.suika.y2005.CSS.Node.FontFaceRule = function () {
491 cx.fam.suika.y2005.CSS.Node.FontFaceRule._superclass.apply
492 (this, ["urn:x-suika-fam-cx:css:", "font-face"]);
493 this.style = new cx.fam.suika.y2005.CSS.Property.MultiValueSet ();
494 };
495 cx.fam.suika.y2005.CSS.Node.FontFaceRule.inherits (cx.fam.suika.y2005.CSS.Node.AtRule);
496 cx.fam.suika.y2005.CSS.Node.FontFaceRule.prototype.getCSSNodeType = function () {
497 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_AT_FONT_FACE_NODE;
498 };
499 cx.fam.suika.y2005.CSS.Node.FontFaceRule.prototype.getType = function () {
500 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.FONT_FACE_RULE;
501 };
502
503 /**
504 The textual representation of the rule.
505 [DOM Level 2 CSS]
506
507 Note that namespace fix up is not done.
508 */
509 cx.fam.suika.y2005.CSS.Node.FontFaceRule.prototype.getCSSText =
510 function () {
511 return "@font-face {\n\n"
512 + this.style.getCSSText ()
513 + "\n}\n";
514 };
515 /* Not implemented: |setCSSText| */
516
517 /**
518 The declaration block of the |@font-face| rule.
519 [DOM Level 2 CSS]
520 */
521 cx.fam.suika.y2005.CSS.Node.FontFaceRule.prototype.getStyle = function () {
522 return this.style;
523 };
524
525 cx.fam.suika.y2005.CSS.Node.FontFaceRule.prototype.toString = function () {
526 return "[object CSSFontFaceRule]";
527 };
528
529
530
531 /**
532 Interface |CSSPageRule|
533 */
534 cx.fam.suika.y2005.CSS.Node.PageRule = function () {
535 cx.fam.suika.y2005.CSS.Node.PageRule._superclass.apply
536 (this, ["urn:x-suika-fam-cx:css:", "page"]);
537 };
538 cx.fam.suika.y2005.CSS.Node.PageRule.inherits (cx.fam.suika.y2005.CSS.Node.AtRule);
539 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.getCSSNodeType = function () {
540 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_AT_PAGE_NODE;
541 };
542 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.getType = function () {
543 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.PAGE_RULE;
544 };
545
546 /**
547 The textual representation of the rule.
548 [DOM Level 2 CSS]
549
550 Note that namespace fixup is not done.
551 */
552 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.getCSSText =
553 function () {
554 var r = "@page";
555 var sel = this.getSelectorText ();
556 if (sel.length > 0) {
557 r += " " + sel;
558 }
559 r += " {\n\n"
560 + this.style.getCSSText ()
561 + "\n}\n";
562 return r;
563 };
564 /* Not implemented: |setCSSText| */
565
566 /**
567 The selector object of the |@page| rule.
568 [non-standard]
569 */
570 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.getSelectorObject = function () {
571 return this.selector;
572 };
573 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.setSelectorObject =
574 function (newValue) {
575 this.selector = newValue;
576 };
577
578 /**
579 The textual representation of selector of the |@page| rule.
580 [DOM Level 2 CSS]
581
582 Note that namespace fixup is not done.
583 */
584 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.getSelectorText = function () {
585 return this.selector.getCSSText ();
586 };
587 /* Not implemented: |setSelectorText| from DOM Level 2 CSS */
588
589 /**
590 The declaration block of the |@page| rule.
591 [DOM Level 2 CSS]
592 */
593 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.getStyle = function () {
594 return this.style;
595 };
596
597 cx.fam.suika.y2005.CSS.Node.PageRule.prototype.toString = function () {
598 return "[object CSSPageRule]";
599 };
600
601
602 /**
603 Interface |CSSImportRule|
604 */
605 cx.fam.suika.y2005.CSS.Node.ImportRule = function (hrefArg, mediaArg) {
606 cx.fam.suika.y2005.CSS.Node.ImportRule._superclass.apply
607 (this, ["urn:x-suika-fam-cx:css:", "import"]);
608 this.href = hrefArg;
609 if (mediaArg) {
610 this.media = mediaArg;
611 } else {
612 /* TODO: set empty media query */
613 }
614 };
615 cx.fam.suika.y2005.CSS.Node.ImportRule.inherits (cx.fam.suika.y2005.CSS.Node.AtRule);
616 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.getCSSNodeType = function () {
617 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_AT_IMPORT_NODE;
618 };
619 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.getType = function () {
620 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.IMPORT_RULE;
621 };
622
623 /**
624 The textual representation of the rule.
625 [DOM Level 2 CSS]
626
627 Note that namespace fix up is not done.
628 */
629 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.getCSSText =
630 function () {
631 var r = '@import "';
632 + this.href.replace (/([\u000A\u000C"\\]|\u000D\u000A?)/g,
633 function (c) { return "\\" + c })
634 + '"';
635 var mq = this.media.getMediaText ();
636 if (mq.length > 0) {
637 r += " " + mq;
638 }
639 r += ";\n";
640 return r;
641 };
642 /* Not implemented: |setCSSText| */
643
644 /**
645 The DOM URI of the style sheet to be imported.
646 [DOM Level 2 CSS]
647 */
648 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.getHref = function () {
649 return this.href;
650 };
651
652 /**
653 The media query of the rule.
654 [DOM Level 2 CSS]
655 */
656 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.getMedia = function () {
657 return this.media;
658 };
659
660 /**
661 The style sheet referred to by the rule, if it has been loaded,
662 or |null| otherwise.
663 [DOM Level 2 CSS]
664 */
665 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.getStyleSheet = function () {
666 return this.styleSheet;
667 };
668 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype._SetStyleSheet = function (newValue) {
669 this.styleSheet = newValue;
670 };
671
672 cx.fam.suika.y2005.CSS.Node.ImportRule.prototype.toString = function () {
673 return "[object CSSImportRule]";
674 };
675
676
677 /**
678 Interface |CSSCharsetRule|
679 */
680 cx.fam.suika.y2005.CSS.Node.CharsetRule = function (encodingArg) {
681 cx.fam.suika.y2005.CSS.Node.CharsetRule._superclass.apply
682 (this, ["urn:x-suika-fam-cx:css:", "charset"]);
683 this.encoding = encodingArg;
684 };
685 cx.fam.suika.y2005.CSS.Node.CharsetRule.inherits (cx.fam.suika.y2005.CSS.Node.AtRule);
686 cx.fam.suika.y2005.CSS.Node.CharsetRule.prototype.getCSSNodeType = function () {
687 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_AT_CHARSET_NODE;
688 };
689 cx.fam.suika.y2005.CSS.Node.CharsetRule.prototype.getType = function () {
690 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CHARSET_RULE;
691 };
692
693 /**
694 The textual representation of the rule.
695 [DOM Level 2 CSS]
696
697 Note that namespace fix up is not done.
698 */
699 cx.fam.suika.y2005.CSS.Node.CharsetRule.prototype.getCSSText =
700 function () {
701 return '@charset "'
702 + this.encoding.replace (/([\u000A\u000C"\\]|\u000D\u000A?)/g,
703 function (c) { return "\\" + c })
704 + '";\n';
705 };
706 /* Not implemented: |setCSSText| */
707
708 /**
709 The charset name.
710 [DOM Level 2 CSS]
711 */
712 cx.fam.suika.y2005.CSS.Node.CharsetRule.prototype.getEncoding = function () {
713 return this.encoding;
714 };
715
716 cx.fam.suika.y2005.CSS.Node.CharsetRule.prototype.toString = function () {
717 return "[object CSSCharsetRule]";
718 };
719
720
721 /**
722 Interface |CSSNameSpaceRule|
723 */
724 cx.fam.suika.y2005.CSS.Node.NamespaceRule = function (prefixArg, namespaceURIArg) {
725 cx.fam.suika.y2005.CSS.Node.NamespaceRule._superclass.apply
726 (this, ["urn:x-suika-fam-cx:css:", "namespace"]);
727 this.prefix = prefixArg;
728 this.namespaceURI = namespaceURIArg;
729 };
730 cx.fam.suika.y2005.CSS.Node.NamespaceRule.inherits
731 (cx.fam.suika.y2005.CSS.Node.AtRule);
732 cx.fam.suika.y2005.CSS.Node.NamespaceRule.prototype.getCSSNodeType = function () {
733 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_AT_NAMESPACE_NODE;
734 };
735 cx.fam.suika.y2005.CSS.Node.NamespaceRule.prototype.getType = function () {
736 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.NAMESPACE_RULE;
737 };
738
739 /**
740 The textual representation of the rule.
741 [DOM Level 2 CSS]
742 */
743 cx.fam.suika.y2005.CSS.Node.NamespaceRule.prototype.getCSSText =
744 function () {
745 var r = "@namespace";
746 if (this.prefix != null) r += " " + this._EscapeIdent (this.prefix);
747 r += ' "'
748 + this.namespaceURI.replace (/([\u000A\u000C"\\]|\u000D\u000A?)/g,
749 function (c) { return "\\" + c })
750 + '";\n';
751 return r;
752 };
753 /* Not implemented: |setCSSText| */
754
755 /**
756 The namespace URI.
757 [non-standard]
758 */
759 cx.fam.suika.y2005.CSS.Node.NamespaceRule.prototype.getNamespaceURI = function () {
760 return this.namespaceURI;
761 };
762 /* Is setter necessary? */
763
764 /**
765 The namespace prefix.
766 [non-standard]
767 */
768 cx.fam.suika.y2005.CSS.Node.NamespaceRule.prototype.getPrefix = function () {
769 return this.prefix;
770 };
771 /* Is setter necessary? */
772
773 cx.fam.suika.y2005.CSS.Node.NamespaceRule.prototype.toString = function () {
774 return "[object CSSNameSpaceRule]";
775 };
776
777
778 /**
779 Interface |CSSUnknownRule|
780 */
781 cx.fam.suika.y2005.CSS.Node.UnknownRule = function (namespaceURI, localName) {
782 cx.fam.suika.y2005.CSS.Node.UnknownRule._superclass.apply
783 (this, [namespaceURI, localName]);
784 };
785 cx.fam.suika.y2005.CSS.Node.UnknownRule.inherits (cx.fam.suika.y2005.CSS.Node.AtRule);
786
787 cx.fam.suika.y2005.CSS.Node.UnknownRule.prototype.toString = function () {
788 return "[object CSSUnknownRule]";
789 };
790 cx.fam.suika.y2005.CSS.Node.UnknownRule.prototype.getCSSNodeType = function () {
791 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_UNKNOWN_RULE_NODE;
792 };
793 cx.fam.suika.y2005.CSS.Node.UnknownRule.prototype.getType = function () {
794 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.UNKNOWN_RULE;
795 };
796
797
798 /**
799 Interface |CSSStyleRule|
800
801 A |CSSStyleRule| object represents a rule set in a CSS style sheet.
802 */
803 cx.fam.suika.y2005.CSS.Node.RuleSet = function (sel) {
804 cx.fam.suika.y2005.CSS.Node.RuleSet._superclass.apply (this, []);
805 this.selector = sel;
806 this.style = new cx.fam.suika.y2005.CSS.Property.MultiValueSet ();
807 this.style.parentRule = this;
808 };
809 cx.fam.suika.y2005.CSS.Node.RuleSet.inherits (cx.fam.suika.y2005.CSS.Node.Rule);
810 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.getCSSNodeType = function () {
811 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_RULE_SET_NODE;
812 };
813 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.getType = function () {
814 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.STYLE_RULE;
815 };
816
817 /**
818 The textual representation of the rule set.
819 [DOM Level 2 CSS]
820
821 Note that namespace fix up is not done.
822 */
823 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.getCSSText =
824 function () {
825 return this.getSelectorText () + " {\n"
826 + this.style.getCSSText ()
827 + "}\n";
828 };
829 /* Not implemented: |setCSSText| from DOM Level 2 CSS */
830
831 /* Not implemented: |setSelectorText| from DOM Level 2 CSS */
832
833 /**
834 The selector object of the rule set.
835 [non-standard]
836 */
837 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.getSelectorObject = function () {
838 return this.selector;
839 };
840 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.setSelectorObject = function (newValue) {
841 this.selector = newValue;
842 };
843
844 /**
845 A textual representation of the selector of the rule set.
846 [DOM Level 2 CSS]
847 */
848 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.getSelectorText = function () {
849 return this.selector.getSelectorText ();
850 };
851
852 /**
853 The declaration block of the rule set.
854 [DOM Level 2 CSS]
855 */
856 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.getStyle = function () {
857 return this.style;
858 };
859
860 cx.fam.suika.y2005.CSS.Node.RuleSet.prototype.toString = function () {
861 return "[object CSSRuleSet]";
862 };
863
864
865 /**
866 Interface |CSSBlock|
867 */
868 cx.fam.suika.y2005.CSS.Node.Block = function () {
869 cx.fam.suika.y2005.CSS.Node.Block._superclass.apply (this, arguments);
870 };
871 cx.fam.suika.y2005.CSS.Node.Block.inherits (cx.fam.suika.y2005.CSS.Node.Node);
872
873 cx.fam.suika.y2005.CSS.Node.Block.prototype.toString = function () {
874 return "[object CSSBlock]";
875 };
876
877
878 /**
879 Interface |CSSStyleDeclaration|
880
881 A |CSSStyleDeclaration| represents a CSS declaration block.
882 */
883 cx.fam.suika.y2005.CSS.Node.StyleDeclaration = function () {
884 cx.fam.suika.y2005.CSS.Node.StyleDeclaration._superclass.apply (this, arguments);
885 this.decls = [];
886 };
887 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.inherits
888 (cx.fam.suika.y2005.CSS.Node.Block);
889 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.getCSSNodeType = function () {
890 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_DECLARATION_BLOCK_NODE;
891 };
892
893 /**
894 Appends a CSS property declaration object.
895 [non-standard]
896 */
897 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.appendPropertyNode =
898 function (newProp) {
899 newProp.parentRule = this;
900 return this.decls.push (newProp);
901 };
902
903 /* Not implemented: |setCSSText|, |length|, |getPropertyCSSValue|,
904 |getPropertyPriority|, |getPropertyValue|,
905 |removeProperty|, |setProperty| from DOM Level 2 CSS */
906
907 /**
908 The textual representation of the declaration block, excluding the
909 surrounding curly braces.
910 [DOM Level 2 CSS]
911
912 Note that namespace fix up is not done.
913 */
914 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.getCSSText =
915 function () {
916 var r = "";
917 for (var i = 0; i < this.decls.length; i++) {
918 r += " " + this.decls[i].getCSSText () + ";\n";
919 }
920 return r;
921 };
922
923 /**
924 The number of declarations in the declaration block.
925 [non-standard]
926 */
927 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.getDeclarationLength =
928 function () {
929 return this.decls.length;
930 };
931
932 /**
933 Returns the |index|th declaration in the declaration block, if any, or |null|.
934 [non-standard]
935
936 @param index The index of the declaration.
937 @return The declaration object or |null|.
938 */
939 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.getDeclarationNode =
940 function (index) {
941 return this.decls[index];
942 };
943
944 /*
945 The rule that contains this rule, if any, or |null| otherwise.
946 [DOM Level 2 CSS]
947 */
948 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.getParentRule = function () {
949 return this.parentRule;
950 };
951 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype._SetParentRule =
952 function (newValue) {
953 this.parentRule = newValue;
954 };
955
956 cx.fam.suika.y2005.CSS.Node.StyleDeclaration.prototype.toString = function () {
957 return "[object CSSStyleDeclaration]";
958 };
959
960
961 /**
962 Interface |CSSDeclaration|
963 */
964 cx.fam.suika.y2005.CSS.Node.Declaration = function () {
965 cx.fam.suika.y2005.CSS.Node.Declaration._superclass.apply (this, arguments);
966 };
967 cx.fam.suika.y2005.CSS.Node.Declaration.inherits (cx.fam.suika.y2005.CSS.Node.Node);
968 cx.fam.suika.y2005.CSS.Node.Declaration.prototype.getCSSNodeType = function () {
969 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_EMPTY_DECLARATION_NODE;
970 };
971
972 /**
973 The textual representation of the declaration.
974 [non-standard]
975
976 Note that namespace fix up is not done.
977 */
978 cx.fam.suika.y2005.CSS.Node.Declaration.prototype.getCSSText =
979 function () {
980 return "";
981 };
982
983 cx.fam.suika.y2005.CSS.Node.Declaration.prototype.toString = function () {
984 return "[object CSSDeclaration]";
985 };
986
987
988 /**
989 Interface |CSSPropertyDeclaration|
990
991 A |CSSPropertyDeclaration| object represents a CSS declaration,
992 i.e. a pair of property (or descriptor) name and value.
993 */
994 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration =
995 function (nsURI, prefix, lname, val, pri) {
996 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration._superclass.apply (this, []);
997 this.propertyNamespaceURI = nsURI;
998 this.propertyPrefix = prefix != null ? prefix.toLowerCase () : null;
999 this.propertyLocalName = lname.toLowerCase ();
1000 this.propertyValue = val;
1001 this.priority = pri;
1002 };
1003 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.inherits
1004 (cx.fam.suika.y2005.CSS.Node.Declaration);
1005 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getCSSNodeType =
1006 function () {
1007 return cx.fam.suika.y2005.CSS.Node.Rule.prototype.CSS_PROPERTY_DECLARATION_NODE;
1008 };
1009
1010 /**
1011 The textual representation of the declaration.
1012 Note that namespace fix up is not done.
1013 [non-standard]
1014 */
1015 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getCSSText =
1016 function () {
1017 var r = this._EscapeIdent (this.getPropertyName ()) + ": "
1018 + this.getPropertyValue ().getCSSText ();
1019 if (this.priority.namespaceURI == "http://suika.fam.cx/~wakaba/archive/2005/cssc." &&
1020 this.priority.localName == "normal") {
1021 //
1022 } else {
1023 r += " !" + this.priority.getCSSText ();
1024 }
1025 return r;
1026 };
1027
1028 /**
1029 The priority value of the property.
1030 */
1031 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getPriority =
1032 function () {
1033 return this.priority;
1034 };
1035 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.setPriority =
1036 function (newValue) {
1037 this.priority = newValue;
1038 };
1039
1040 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getPropertyLocalName =
1041 function () {
1042 return this.propertyLocalName;
1043 };
1044 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getPropertyName =
1045 function () {
1046 if (this.propertNamePrefix == null) {
1047 return this.propertyLocalName;
1048 } else {
1049 return "-" + this.propertyPrefix + "-" + this.propertyLocalName;
1050 }
1051 };
1052 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getPropertyPrefix =
1053 function () {
1054 return this.propertyPrefix;
1055 };
1056 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.setPropertyPrefix =
1057 function (newValue) {
1058 this.propertyPrefix = newValue.toLowerCase ();
1059 };
1060 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getPropertyNamespaceURI =
1061 function () {
1062 return this.propertyNamespaceURI;
1063 };
1064 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.getPropertyValue =
1065 function () {
1066 return this.propertyValue;
1067 };
1068 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.setPropertyValue =
1069 function (newValue) {
1070 this.propertyValue = newValue;
1071 };
1072
1073 cx.fam.suika.y2005.CSS.Node.PropertyDeclaration.prototype.toString = function () {
1074 return "[object CSSPropertyDeclaration]";
1075 };
1076
1077
1078 /**
1079 Interface |StyleSheetList|
1080 */
1081 cx.fam.suika.y2005.CSS.StyleSheetList = function () {
1082 this.v = [];
1083 };
1084
1085 /**
1086 Appends a style sheet to the last of the list.
1087 [non-standard]
1088
1089 @param styleSheet The style sheet to add.
1090 @throw DOMException |NO_MODIFICATION_ALLOWED_ERR|: If the list is read-only.
1091 */
1092 cx.fam.suika.y2005.CSS.StyleSheetList.prototype.addStyleSheet = function (styleSheet) {
1093 this.v.push (styleSheet);
1094 };
1095
1096 /**
1097 The |index|th style sheet in the list, if any, or |null| otherwise.
1098 [DOM Level 2 Style Sheet]
1099 */
1100 cx.fam.suika.y2005.CSS.StyleSheetList.prototype.item = function (index) {
1101 return this.v[index];
1102 };
1103
1104 /**
1105 The number of style sheets in the list.
1106 [DOM Level 2 Style Sheet]
1107 */
1108 cx.fam.suika.y2005.CSS.StyleSheetList.prototype.getLength = function () {
1109 return this.v.length;
1110 };
1111
1112 cx.fam.suika.y2005.CSS.StyleSheetList.prototype.toString = function () {
1113 return "[object StyleSheetList]";
1114 };
1115
1116
1117 /**
1118 Interface |CSSRuleList|
1119 */
1120 cx.fam.suika.y2005.CSS.RuleList = function () {
1121 this.v = [];
1122 };
1123
1124 /**
1125 Appends a CSS rule to the list.
1126 [non-standard]
1127
1128 Note. In the current implementation this method does not set
1129 |parentRule| and |parentStyleSheet| properties; use
1130 |CSSRule.appendCSSRule| or |CSSStyleSheet.appendCSSRule|
1131 method instead.
1132 This method is intended for contexts where the |CSSRuleList| is
1133 not part of any CSS style sheet.
1134
1135 @param rule The rule to add.
1136 @throw DOMException |NO_MODIFICATION_ALLOWED_ERR|: If the list is read-only.
1137 |HIERARCHY_REQUEST_ERR|: If the type of rule is not
1138 allowed in the list.
1139 */
1140 cx.fam.suika.y2005.CSS.RuleList.prototype.addCSSRule = function (rule) {
1141 this.v.push (rule);
1142 };
1143
1144 /**
1145 The |index|th rule in the list, if any, or |null| otherwise.
1146 [DOM Level 2 CSS]
1147 */
1148 cx.fam.suika.y2005.CSS.RuleList.prototype.item = function (index) {
1149 return this.v[index];
1150 };
1151
1152 /**
1153 The number of rules in the list.
1154 [DOM Level 2 CSS]
1155 */
1156 cx.fam.suika.y2005.CSS.RuleList.prototype.getLength = function () {
1157 return this.v.length;
1158 };
1159
1160 cx.fam.suika.y2005.CSS.RuleList.prototype.toString = function () {
1161 return "[object CSSRuleList]";
1162 };
1163
1164 /* Revision: $Date: 2007/12/30 03:09:38 $ */
1165
1166 /* ***** BEGIN LICENSE BLOCK *****
1167 * Copyright 2005 Wakaba <w@suika.fam.cx>. All rights reserved.
1168 *
1169 * This program is free software; you can redistribute it and/or
1170 * modify it under the same terms as Perl itself.
1171 *
1172 * Alternatively, the contents of this file may be used
1173 * under the following terms (the "MPL/GPL/LGPL"),
1174 * in which case the provisions of the MPL/GPL/LGPL are applicable instead
1175 * of those above. If you wish to allow use of your version of this file only
1176 * under the terms of the MPL/GPL/LGPL, and not to allow others to
1177 * use your version of this file under the terms of the Perl, indicate your
1178 * decision by deleting the provisions above and replace them with the notice
1179 * and other provisions required by the MPL/GPL/LGPL. If you do not delete
1180 * the provisions above, a recipient may use your version of this file under
1181 * the terms of any one of the Perl or the MPL/GPL/LGPL.
1182 *
1183 * "MPL/GPL/LGPL":
1184 *
1185 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
1186 *
1187 * The contents of this file are subject to the Mozilla Public License Version
1188 * 1.1 (the "License"); you may not use this file except in compliance with
1189 * the License. You may obtain a copy of the License at
1190 * <http://www.mozilla.org/MPL/>
1191 *
1192 * Software distributed under the License is distributed on an "AS IS" basis,
1193 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
1194 * for the specific language governing rights and limitations under the
1195 * License.
1196 *
1197 * The Original Code is BIDOM code.
1198 *
1199 * The Initial Developer of the Original Code is Wakaba.
1200 * Portions created by the Initial Developer are Copyright (C) 2005
1201 * the Initial Developer. All Rights Reserved.
1202 *
1203 * Contributor(s):
1204 * Wakaba <w@suika.fam.cx>
1205 *
1206 * Alternatively, the contents of this file may be used under the terms of
1207 * either the GNU General Public License Version 2 or later (the "GPL"), or
1208 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
1209 * in which case the provisions of the GPL or the LGPL are applicable instead
1210 * of those above. If you wish to allow use of your version of this file only
1211 * under the terms of either the GPL or the LGPL, and not to allow others to
1212 * use your version of this file under the terms of the MPL, indicate your
1213 * decision by deleting the provisions above and replace them with the notice
1214 * and other provisions required by the LGPL or the GPL. If you do not delete
1215 * the provisions above, a recipient may use your version of this file under
1216 * the terms of any one of the MPL, the GPL or the LGPL.
1217 *
1218 * ***** END LICENSE BLOCK ***** */

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24