Exemple #1
0
        public override void Apply(ComputedStyle style, Value value)
        {
            if (value == null)
            {
                // Assume none if blank:
                style.DisplayNone();
            }
            else
            {
                switch (value.Text)
                {
                case "block":
                    style.Display = DisplayType.Block;

                    if (!style.FixedWidth && style.Element.parentNode != null)
                    {
                        // Inherit the width here.
                        style.SetPixelWidth(true);

                        // And bubble upwards:
                        style.Element.SetWidthForKids(style);
                    }

                    break;

                case "table-cell":
                    style.Display = DisplayType.TableCell;
                    break;

                case "inline-block":
                    style.Display = DisplayType.InlineBlock;
                    break;

                case "inline":
                    style.Display = DisplayType.Inline;
                    style.EnforceNoInline();
                    break;

                default:
                    style.DisplayNone();
                    break;
                }
            }

            style.RequestLayout();
        }
        /// <summary>Recalculates the tab size of a scroll bar.</summary>
        public virtual void RecalculateTab()
        {
            if (ScrollTab == null)
            {
                if (Element.childNodes.Count > 1)
                {
                    Element scrollTab = Element.childNodes[1];

                    if (scrollTab != null)
                    {
                        ScrollTab = ((ScrollTabTag)scrollTab.Handler);
                    }
                }
            }

            if (ScrollTab != null)
            {
                Element target = GetTarget();
                if (target == null)
                {
                    return;
                }
                ComputedStyle computed = target.style.Computed;

                bool         useX         = ScrollTab.UseX();
                OverflowType overflowMode = useX?computed.OverflowX : computed.OverflowY;
                float        visible      = useX?computed.VisiblePercentageX() : computed.VisiblePercentageY();

                if (visible > 1f)
                {
                    visible = 1f;
                }
                else if (visible < 0f)
                {
                    visible = 0f;
                }

                if (overflowMode == OverflowType.Auto)
                {
                    // Handle AUTO here.
                    // Hide the bar by directly setting it's display style if the whole thing is visible - i.e. visible = 1(00%).
                    ComputedStyle barStyle = Element.Style.Computed;
                    if (visible == 1f)
                    {
                        barStyle.DisplayNone();
                    }
                    else if (barStyle.Display == DisplayType.None)
                    {
                        // Make it visible again:
                        barStyle.Display = DisplayType.InlineBlock;
                    }
                }
                ScrollTab.ApplyTabSize(visible);
            }
        }
//--------------------------------------