1 | // <developer>niklas@protocol7.com</developer>
|
---|
2 | // <completed>100</completed>
|
---|
3 |
|
---|
4 | using System;
|
---|
5 |
|
---|
6 | namespace SharpVectors.Dom.Css
|
---|
7 | {
|
---|
8 | /// <summary>
|
---|
9 | /// Internal class that stores a style in a declaration block
|
---|
10 | /// </summary>
|
---|
11 | internal sealed class CssStyleBlock
|
---|
12 | {
|
---|
13 | #region Constructors
|
---|
14 |
|
---|
15 | internal CssStyleBlock(string name, string val, string priority, CssStyleSheetType origin)
|
---|
16 | {
|
---|
17 | Name = name.Trim();
|
---|
18 | Value = val.Trim();
|
---|
19 | Priority = priority.Trim();
|
---|
20 | Origin = origin;
|
---|
21 | }
|
---|
22 |
|
---|
23 | internal CssStyleBlock(string name, string val, string priority, int specificity,
|
---|
24 | CssStyleSheetType origin) : this(name, val, priority, origin)
|
---|
25 | {
|
---|
26 | Specificity = specificity;
|
---|
27 | }
|
---|
28 |
|
---|
29 | internal CssStyleBlock(CssStyleBlock style, int specificity, CssStyleSheetType origin)
|
---|
30 | : this(style.Name, style.Value, style.Priority, origin)
|
---|
31 | {
|
---|
32 | Specificity = specificity;
|
---|
33 | }
|
---|
34 |
|
---|
35 | #endregion
|
---|
36 |
|
---|
37 | #region Public properties
|
---|
38 |
|
---|
39 | internal string CssText
|
---|
40 | {
|
---|
41 | get
|
---|
42 | {
|
---|
43 | string ret = Name + ":" + Value;
|
---|
44 | if(Priority != null && Priority.Length > 0)
|
---|
45 | {
|
---|
46 | ret += " !" + Priority;
|
---|
47 | }
|
---|
48 | return ret;
|
---|
49 | }
|
---|
50 | }
|
---|
51 |
|
---|
52 | /// <summary>
|
---|
53 | /// The type of the owner stylesheet
|
---|
54 | /// </summary>
|
---|
55 | internal CssStyleSheetType Origin;
|
---|
56 | /// <summary>
|
---|
57 | /// The property name
|
---|
58 | /// </summary>
|
---|
59 | internal string Name;
|
---|
60 | /// <summary>
|
---|
61 | /// The value of the style
|
---|
62 | /// </summary>
|
---|
63 | internal string Value;
|
---|
64 | /// <summary>
|
---|
65 | /// The prioroty of the style, e.g. "important"
|
---|
66 | /// </summary>
|
---|
67 | internal string Priority;
|
---|
68 | /// <summary>
|
---|
69 | /// The calculated specificity of the owner selector
|
---|
70 | /// </summary>
|
---|
71 | internal int Specificity = -1;
|
---|
72 |
|
---|
73 | public CssValue CssValue;
|
---|
74 |
|
---|
75 | #endregion
|
---|
76 | }
|
---|
77 | }
|
---|