Used internally for collection of styles for a specific element
상속: CssStyleDeclaration
예제 #1
0
        public virtual ICssStyleDeclaration GetComputedStyle(string pseudoElt)
        {
            CssXmlDocument ownerDoc = this.OwnerDocument;

            if (_isImported && _importDocument != null && _importNode != null)
            {
                ownerDoc = _importDocument;
            }

            if (_cachedCSD == null)
            {
                CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(this);
                MediaList currentMedia           = ownerDoc.Media;

                if (ownerDoc.UserAgentStyleSheet != null)
                {
                    ownerDoc.UserAgentStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd);
                }
                ((StyleSheetList)ownerDoc.StyleSheets).GetStylesForElement(this, pseudoElt, csd);

                ((CssStyleDeclaration)Style).GetStylesForElement(csd, 0);

                if (ownerDoc.UserStyleSheet != null)
                {
                    ownerDoc.UserStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd);
                }

                _cachedCSD = csd;
            }
            return(_cachedCSD);
        }
 public void CollectOverrideLowerSpecificity()
 {
     XmlElement elm = getElm();
             CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm);
             csd.CollectProperty("foo", 100, _getCssValue("value1"), CssStyleSheetType.Author, "");
             csd.CollectProperty("foo", 1, _getCssValue("value2"), CssStyleSheetType.Author, "");
             Assert.AreEqual("foo:value1;", csd.CssText);
 }
예제 #3
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 protected internal override void GetStylesForElement(XmlElement elt, string pseudoElt,
                                                      MediaList ml, CssCollectedStyleDeclaration csd)
 {
     if (_media.Matches(ml))
     {
         ((CssRuleList)CssRules).GetStylesForElement(elt, pseudoElt, ml, csd);
     }
 }
 public void CollectOverrideImportantUserAgent()
 {
     XmlElement elm = getElm();
             CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm);
             csd.CollectProperty("foo", 100, _getCssValue("value1"), CssStyleSheetType.UserAgent, "");
             csd.CollectProperty("foo", 1, _getCssValue("value2"), CssStyleSheetType.UserAgent, "important");
             Assert.AreEqual("foo:value1;", csd.CssText);
 }
예제 #5
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 internal void GetStylesForElement(CssCollectedStyleDeclaration csd, int specificity)
 {
     foreach (DictionaryEntry de in styles)
     {
         SharpCssStyle scs = (SharpCssStyle)de.Value;
         csd.CollectProperty(scs.Name, specificity, (CssValue)GetPropertyCssValue(scs.Name), scs.Origin, scs.Priority);
     }
 }
예제 #6
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 public void GetStylesForElement(CssCollectedStyleDeclaration csd, int specificity)
 {
     foreach (KeyValuePair <string, CssStyleBlock> de in _styles)
     {
         CssStyleBlock scs = de.Value;
         csd.CollectProperty(scs.Name, specificity,
                             (CssValue)GetPropertyCssValue(scs.Name), scs.Origin, scs.Priority);
     }
 }
    public void Collect()
    {
        XmlElement elm = getElm();
                CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm);
                Assert.AreEqual(0, csd.Length);
                csd.CollectProperty("foo", 1, _getCssValue("12px"), CssStyleSheetType.Author, "important");
                Assert.AreEqual(1, csd.Length);
                Assert.AreEqual("foo:12px !important;", csd.CssText);

                csd.CollectProperty("bar", 1, _getCssValue("test"), CssStyleSheetType.Author, "");
                Assert.AreEqual(2, csd.Length);
                Assert.AreEqual("foo:12px !important;bar:test;", csd.CssText);
    }
예제 #8
0
        /// <summary>
        /// Used to find matching style rules in the cascading order
        /// </summary>
        /// <param name="elt">The element to find styles for</param>
        /// <param name="pseudoElt">The pseudo-element to find styles for</param>
        /// <param name="ml">The medialist that the document is using</param>
        /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
        protected internal override void GetStylesForElement(XmlElement elt, string pseudoElt,
                                                             MediaList ml, CssCollectedStyleDeclaration csd)
        {
            XPathNavigator nav = elt.CreateNavigator();

            foreach (CssXPathSelector sel in _xPathSelectors)
            {
                // TODO: deal with pseudoElt
                if (sel != null && sel.Matches(nav))
                {
                    ((CssStyleDeclaration)Style).GetStylesForElement(csd, sel.Specificity);
                    break;
                }
            }
        }
예제 #9
0
        public virtual ICssStyleDeclaration GetComputedStyle(string pseudoElt)
        {
            if (cachedCSD == null)
            {
                CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(this);
                MediaList currentMedia           = OwnerDocument.Media;

                if (OwnerDocument.UserAgentStyleSheet != null)
                {
                    OwnerDocument.UserAgentStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd);
                }
                ((StyleSheetList)OwnerDocument.StyleSheets).GetStylesForElement(this, pseudoElt, csd);

                ((CssStyleDeclaration)Style).GetStylesForElement(csd, 0);

                if (OwnerDocument.UserStyleSheet != null)
                {
                    OwnerDocument.UserStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd);
                }

                cachedCSD = csd;
            }
            return(cachedCSD);
        }
예제 #10
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 protected internal virtual void GetStylesForElement(XmlElement elt, string pseudoElt, 
     MediaList ml, CssCollectedStyleDeclaration csd)
 {
 }
예제 #11
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 internal void GetStylesForElement(XmlElement elt, string pseudoElt, MediaList ml, CssCollectedStyleDeclaration csd)
 {
     ulong len = Length;
     for(ulong i = 0; i<len; i++)
     {
         CssRule csr = (CssRule)this[i];
         csr.GetStylesForElement(elt, pseudoElt, ml, csd);
     }
 }
예제 #12
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 protected internal virtual void GetStylesForElement(XmlElement elt,
                                                     string pseudoElt, MediaList ml, CssCollectedStyleDeclaration csd)
 {
 }
예제 #13
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 protected internal override void GetStylesForElement(XmlElement elt, string pseudoElt, MediaList ml, CssCollectedStyleDeclaration csd)
 {
     XPathNavigator nav = elt.CreateNavigator();
     foreach(CssXPathSelector sel in XPathSelectors)
     {
         // TODO: deal with pseudoElt
         if(sel != null && sel.Matches(nav))
         {
             ((CssStyleDeclaration)Style).GetStylesForElement(csd, sel.Specificity);
             break;
         }
     }
 }
예제 #14
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 protected internal override void GetStylesForElement(XmlElement elt, string pseudoElt, MediaList ml, CssCollectedStyleDeclaration csd)
 {
     if(((MediaList)Media).Matches(ml))
     {
         ((CssRuleList)CssRules).GetStylesForElement(elt, pseudoElt, ml, csd);
     }
 }
예제 #15
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 public void GetStylesForElement(XmlElement elt, string pseudoElt, CssCollectedStyleDeclaration csd)
 {
     GetStylesForElement(elt, pseudoElt, csd, doc.Media);
 }
예제 #16
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 internal void GetStylesForElement(XmlElement elt, string pseudoElt, CssCollectedStyleDeclaration csd, MediaList ml)
 {
     foreach (StyleSheet ss in styleSheets)
     {
         ss.GetStylesForElement(elt, pseudoElt, ml, csd);
     }
 }
예제 #17
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 internal void GetStylesForElement(CssCollectedStyleDeclaration csd, int specificity)
 {
     foreach (KeyValuePair<string, CssStyleBlock> de in styles)
     {
         CssStyleBlock scs = de.Value;
         csd.CollectProperty(scs.Name, specificity,
             (CssValue)GetPropertyCssValue(scs.Name), scs.Origin, scs.Priority);
     }
 }
예제 #18
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 /// <param name="elt">The element to find styles for</param>
 /// <param name="pseudoElt">The pseudo-element to find styles for</param>
 /// <param name="ml">The medialist that the document is using</param>
 /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
 protected internal override void GetStylesForElement(XmlElement elt, string pseudoElt, MediaList ml, CssCollectedStyleDeclaration csd)
 {
     if(media.Matches(ml))
     {
         ((CssStyleSheet)StyleSheet).GetStylesForElement(elt, pseudoElt, ml, csd);
     }
 }
예제 #19
0
        /// <summary>
        /// Used to find matching style rules in the cascading order
        /// </summary>
        /// <param name="elt">The element to find styles for</param>
        /// <param name="pseudoElt">The pseudo-element to find styles for</param>
        /// <param name="ml">The medialist that the document is using</param>
        /// <param name="csd">A CssStyleDeclaration that holds the collected styles</param>
        internal void GetStylesForElement(XmlElement elt, string pseudoElt, MediaList ml, CssCollectedStyleDeclaration csd)
        {
            ulong len = Length;

            for (ulong i = 0; i < len; i++)
            {
                CssRule csr = (CssRule)this[i];
                csr.GetStylesForElement(elt, pseudoElt, ml, csd);
            }
        }
예제 #20
0
        public virtual ICssStyleDeclaration GetComputedStyle(string pseudoElt)
        {
            if(cachedCSD == null)
            {
                CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(this);
                MediaList currentMedia = OwnerDocument.Media;

                if(OwnerDocument.UserAgentStyleSheet != null)
                {
                    OwnerDocument.UserAgentStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd);
                }
                ((StyleSheetList)OwnerDocument.StyleSheets).GetStylesForElement(this, pseudoElt, csd);

                ((CssStyleDeclaration)Style).GetStylesForElement(csd, 0);

                if(OwnerDocument.UserStyleSheet != null)
                {
                    OwnerDocument.UserStyleSheet.GetStylesForElement(this, pseudoElt, currentMedia, csd);
                }

                cachedCSD = csd;
            }
            return cachedCSD;
        }
예제 #21
0
 /// <summary>
 /// Used to find matching style rules in the cascading order
 /// </summary>
 internal void GetStylesForElement(CssCollectedStyleDeclaration csd, int specificity)
 {
     foreach(DictionaryEntry de in styles)
     {
         SharpCssStyle scs = (SharpCssStyle)de.Value;
         csd.CollectProperty(scs.Name, specificity, (CssValue)GetPropertyCssValue(scs.Name), scs.Origin, scs.Priority);
     }
 }
    public void TestExsNotFontSize()
    {
        CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(getElm());
                csd.CollectProperty("notFontSize", 1, CssValue.GetCssValue("2ex", false), CssStyleSheetType.Author, "");

                CssPrimitiveValue cssPrimValue = csd.GetPropertyCssValue("notFontSize") as CssPrimitiveValue;
                Assert.AreEqual(10, cssPrimValue.GetFloatValue(CssPrimitiveType.Px));
    }
    public void TestFuncAttr()
    {
        XmlElement elm = getElm();
                elm.SetAttribute("kalle", "", "roffe");
                CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(elm);
                csd.CollectProperty("foo", 1, CssValue.GetCssValue("attr(kalle)", false), CssStyleSheetType.Author, "");

                CssPrimitiveValue cssPrimValue = csd.GetPropertyCssValue("foo") as CssPrimitiveValue;
                Assert.IsNotNull(cssPrimValue);
                Assert.AreEqual("roffe", cssPrimValue.GetStringValue());
    }
 protected override CssStyleDeclaration getCSD()
 {
     CssCollectedStyleDeclaration csd = new CssCollectedStyleDeclaration(getElm());
             csd.CollectProperty("foo", 1, _getCssValue("bar"), CssStyleSheetType.Author, String.Empty);
             csd.CollectProperty("length", 1, _getCssValue("23cm"), CssStyleSheetType.Author, "important");
             return csd;
 }