Ejemplo n.º 1
0
        protected void ImplSetAttribute(DomAttribute attr)
        {
            //handle some attribute
            //special for some attributes

            switch ((WellknownName)attr.LocalNameIndex)
            {
            case WellknownName.Style:
            {
                //TODO: parse and evaluate style here
                //****
                WebDom.Parser.CssParser miniCssParser = CssParserPool.GetFreeParser();
                //parse and evaluate the ruleset
                CssRuleSet parsedRuleSet = miniCssParser.ParseCssPropertyDeclarationList(attr.Value.ToCharArray());

                Css.BoxSpec spec = null;
                if (this.ParentNode != null)
                {
                    spec = ((HtmlElement)this.ParentNode).Spec;
                }
                foreach (WebDom.CssPropertyDeclaration propDecl in parsedRuleSet.GetAssignmentIter())
                {
                    SpecSetter.AssignPropertyValue(
                        _boxSpec,
                        spec,
                        propDecl);
                }
                CssParserPool.ReleaseParser(ref miniCssParser);
            }
            break;
            }
        }
Ejemplo n.º 2
0
        public override void SetAttribute(DomAttribute attr)
        {
            base.SetAttribute(attr); //to base
            //----------------------

            switch ((WellknownName)attr.LocalNameIndex)
            {
            case WellknownName.Src:
            {
                switch (this.WellknownElementName)
                {
                case WellKnownDomNodeName.img:
                {
                    if (_principalBox != null)
                    {
                        CssBoxImage boxImg = (CssBoxImage)_principalBox;
                        boxImg.ImageBinder = new ImageBinder(attr.Value);
                        boxImg.InvalidateGraphics();
                    }
                }
                break;
                }
            }
            break;

            case WellknownName.Style:
            {
                //TODO: parse and evaluate style here
                //****
                WebDom.Parser.CssParser miniCssParser = CssParserPool.GetFreeParser();
                //parse and evaluate the ruleset
                CssRuleSet parsedRuleSet = miniCssParser.ParseCssPropertyDeclarationList(attr.Value.ToCharArray());

                Css.BoxSpec spec = null;
                if (this.ParentNode != null)
                {
                    spec = ((HtmlElement)this.ParentNode).Spec;
                }
                foreach (WebDom.CssPropertyDeclaration propDecl in parsedRuleSet.GetAssignmentIter())
                {
                    SpecSetter.AssignPropertyValue(
                        _boxSpec,
                        spec,
                        propDecl);
                }
                CssParserPool.ReleaseParser(ref miniCssParser);
            }
            break;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Parse the given stylesheet source to CSS blocks dictionary.<br/>
 /// The CSS blocks are organized into two level buckets of media type and class name.<br/>
 /// Root media type are found under 'all' bucket.<br/>
 /// The parsed css blocks are added to the given css data, merged if class name already exists.
 /// </summary>
 /// <param name="cssData">the CSS data to fill with parsed CSS objects</param>
 /// <param name="cssTextSource">raw css stylesheet to parse</param>
 public static void ParseStyleSheet(WebDom.CssActiveSheet cssData, string cssTextSource)
 {
     if (!String.IsNullOrEmpty(cssTextSource))
     {
         var parser = new WebDom.Parser.CssParser();
         parser.ParseCssStyleSheet(cssTextSource.ToCharArray());
         //-----------------------------------
         WebDom.CssDocument    cssDoc       = parser.OutputCssDocument;
         WebDom.CssActiveSheet cssActiveDoc = new WebDom.CssActiveSheet();
         cssActiveDoc.LoadCssDoc(cssDoc);
         if (cssData != null)
         {
             //merge ?
             cssData.Combine(cssActiveDoc);
         }
         else
         {
             //cssData.ActiveDoc = cssActiveDoc;
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Parse the given stylesheet source to CSS blocks dictionary.<br/>
 /// The CSS blocks are organized into two level buckets of media type and class name.<br/>
 /// Root media type are found under 'all' bucket.<br/>
 /// The parsed css blocks are added to the given css data, merged if class name already exists.
 /// </summary>
 /// <param name="cssData">the CSS data to fill with parsed CSS objects</param>
 /// <param name="cssTextSource">raw css stylesheet to parse</param>
 public static void ParseStyleSheet(WebDom.CssActiveSheet cssData, string cssTextSource)
 {
     if (!String.IsNullOrEmpty(cssTextSource))
     {
         var parser = new WebDom.Parser.CssParser();
         parser.ParseCssStyleSheet(cssTextSource.ToCharArray());
         //-----------------------------------
         WebDom.CssDocument cssDoc = parser.OutputCssDocument;
         WebDom.CssActiveSheet cssActiveDoc = new WebDom.CssActiveSheet();
         cssActiveDoc.LoadCssDoc(cssDoc);
         if (cssData != null)
         {
             //merge ?
             cssData.Combine(cssActiveDoc);
         }
         else
         {
             //cssData.ActiveDoc = cssActiveDoc;
         }
     }
 }
Ejemplo n.º 5
0
 public static void ReleaseParser(ref WebDom.Parser.CssParser parser)
 {
     s_pool.Push(parser);
 }