Inheritance: SharpVectors.Dom.Element, IElementCssInlineStyle
Beispiel #1
0
        public void NodeChangedEvent(Object src, XmlNodeChangedEventArgs args)
        {
            if (!Static)
            {
                #region Attribute updates
                // xmlns:xml is auto-inserted whenever a selectNode is performed, we don't want those events
                if (args.Node is XmlText && args.NewParent is XmlAttribute && args.NewParent.Name != "xmlns:xml")
                {
                    XmlAttribute  attr = args.NewParent as XmlAttribute;
                    CssXmlElement elm  = attr.OwnerElement as CssXmlElement;
                    if (elm != null)
                    {
                        elm.AttributeChange(attr, args);
                    }
                }
                else if (args.Node is XmlAttribute && args.Node.Name != "xmlns:xml")
                {
                    // the cause of the change is a XmlAttribute => happens during inserting or removing
                    CssXmlElement oldElm = args.OldParent as CssXmlElement;
                    if (oldElm != null)
                    {
                        oldElm.AttributeChange(args.Node, args);
                    }

                    CssXmlElement newElm = args.NewParent as CssXmlElement;
                    if (newElm != null)
                    {
                        newElm.AttributeChange(args.Node, args);
                    }
                }
                #endregion

                #region OnElementChange
                if (args.Node is XmlText && args.NewParent is XmlElement)
                {
                    CssXmlElement element = (CssXmlElement)args.NewParent;
                    element.ElementChange(src, args);
                }
                else if (args.Node is CssXmlElement)
                {
                    if (args.Action == XmlNodeChangedAction.Insert || args.Action == XmlNodeChangedAction.Change)
                    {
                        // Changes to a child XML node may affect the sibling offsets (for example in tspan)
                        // By calling the parent's OnElementChange, invalidation will propogate back to Node
                        CssXmlElement newParent = (CssXmlElement)args.NewParent;
                        newParent.ElementChange(src, args);
                    }

                    if (args.Action == XmlNodeChangedAction.Remove)
                    {
                        // Removing a child XML node may affect the sibling offsets (for example in tspan)
                        CssXmlElement oldParent = (CssXmlElement)args.OldParent;
                        oldParent.ElementChange(src, args);
                    }
                }
                #endregion
            }
        }
Beispiel #2
0
        protected void FireChildNodeChange(Object src, XmlNodeChangedEventArgs args, bool fireEvent)
        {
            if (fireEvent && childNodeChangeHandler != null)
            {
                childNodeChangeHandler(src, args);
            }

            CssXmlElement cssParent = ParentNode as CssXmlElement;

            if (cssParent != null)
            {
                cssParent.ChildNodeChange(src, args);
            }
        }
Beispiel #3
0
        protected void FireParentNodeChange(Object src, XmlNodeChangedEventArgs args, bool fireEvent)
        {
            if (fireEvent && parentNodeChangeHandler != null)
            {
                parentNodeChangeHandler(src, args);
            }

            foreach (XmlNode child in ChildNodes)
            {
                if (child.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                CssXmlElement cssChild = child as CssXmlElement;

                if (cssChild != null)
                {
                    cssChild.ParentNodeChange(src, args);
                }
            }
        }
Beispiel #4
0
        public void NodeChangedEvent(object src, XmlNodeChangedEventArgs args)
        {
            if (_isStatic || args.Node == null || args.NewParent == null)
            {
                return;
            }
            var comparer = StringComparison.OrdinalIgnoreCase;

            var nodeType       = args.Node.NodeType;
            var parentNodeType = args.NewParent.NodeType;

            // Attribute updates
            // xmlns:xml is auto-inserted whenever a selectNode is performed, we don't want those events
            if (nodeType == XmlNodeType.Text && parentNodeType == XmlNodeType.Attribute &&
                !string.Equals(args.NewParent.Name, XmlConstants.XmlNamespacePrefix, comparer))
            {
                XmlAttribute  attr = args.NewParent as XmlAttribute;
                CssXmlElement elm  = attr.OwnerElement as CssXmlElement;
                if (elm != null)
                {
                    elm.AttributeChange(attr, args);
                }
            }
            else if (nodeType == XmlNodeType.Attribute &&
                     !string.Equals(args.Node.Name, XmlConstants.XmlNamespacePrefix, comparer))
            {
                // the cause of the change is a XmlAttribute => happens during inserting or removing
                CssXmlElement oldElm = args.OldParent as CssXmlElement;
                if (oldElm != null)
                {
                    oldElm.AttributeChange(args.Node, args);
                }

                CssXmlElement newElm = args.NewParent as CssXmlElement;
                if (newElm != null)
                {
                    newElm.AttributeChange(args.Node, args);
                }
            }

            // OnElementChange
            if (nodeType == XmlNodeType.Text && parentNodeType == XmlNodeType.Element)
            {
                CssXmlElement element = (CssXmlElement)args.NewParent;
                element.ElementChange(src, args);
            }
            else if (args.Node is CssXmlElement)
            {
                if (args.Action == XmlNodeChangedAction.Insert || args.Action == XmlNodeChangedAction.Change)
                {
                    // Changes to a child XML node may affect the sibling offsets (for example in tspan)
                    // By calling the parent's OnElementChange, invalidation will propogate back to Node
                    CssXmlElement newParent = (CssXmlElement)args.NewParent;
                    newParent.ElementChange(src, args);
                }
                else if (args.Action == XmlNodeChangedAction.Remove)
                {
                    // Removing a child XML node may affect the sibling offsets (for example in tspan)
                    CssXmlElement oldParent = (CssXmlElement)args.OldParent;
                    oldParent.ElementChange(src, args);
                }
            }
        }