コード例 #1
0
ファイル: HtmlElements.cs プロジェクト: brezza92/HtmlRenderer
        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;
            }
        }
コード例 #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;
            }
        }