Пример #1
0
        public void SetStyleProperty(UIElement element, StyleProperty property)
        {
            if (element.isDisabled)
            {
                return;
            }

            AddToChangeSet(element, property);

            if (!StyleUtil.IsInherited(property.propertyId) || element.children == null || element.children.Count == 0)
            {
                return;
            }

            if (!property.hasValue)
            {
                UIElement ptr = element.parent;

                StyleProperty parentProperty = new StyleProperty(property.propertyId);

                while (ptr != null)
                {
                    parentProperty = ptr.style.GetPropertyValue(property.propertyId);
                    if (parentProperty.hasValue)
                    {
                        break;
                    }

                    ptr = ptr.parent;
                }

                if (!parentProperty.hasValue)
                {
                    parentProperty = DefaultStyleValues_Generated.GetPropertyValue(property.propertyId);
                }

                property = parentProperty;
            }

            for (int i = 0; i < element.children.Count; i++)
            {
                s_ElementStack.Push(element.children[i]);
            }

            while (s_ElementStack.Count > 0)
            {
                UIElement descendant = s_ElementStack.Pop();

                if (!descendant.style.SetInheritedStyle(property))
                {
                    continue;
                }

                // todo -- we might want to cache font size lookups for em values, this would be the place
                // if (property.propertyId == StylePropertyId.TextFontSize) {
                // do caching
                // }

                AddToChangeSet(descendant, property);

                if (descendant.children == null)
                {
                    continue;
                }

                for (int i = 0; i < descendant.children.Count; i++)
                {
                    s_ElementStack.Push(descendant.children[i]);
                }
            }
        }