Example #1
0
        /// <summary>
        /// Measures the bounds of box and children, recursively.<br/>
        /// Performs layout of the DOM structure creating lines by set bounds restrictions.
        /// </summary>
        /// <param name="g">Device context to use</param>
        protected override void PerformLayoutImp(IGraphics g)
        {
            if (Display == CssConstants.None)
            {
                return;
            }

            RectanglesReset();

            CssBox prevSibling = DomUtils.GetPreviousSibling(this);
            float  left        = ContainingBlock.Location.X + ContainingBlock.ActualPaddingLeft + ActualMarginLeft +
                                 ContainingBlock.ActualBorderLeftWidth;
            float top = (prevSibling == null && ParentBox != null
                             ? ParentBox.ClientTop
                             : ParentBox == null ? Location.Y : 0) + MarginTopCollapse(prevSibling) +
                        (prevSibling != null ? prevSibling.ActualBottom + prevSibling.ActualBorderBottomWidth : 0);

            Location     = new PointF(left, top);
            ActualBottom = top;

            //width at 100% (or auto)
            float minwidth = GetMinimumWidth();
            float width    = ContainingBlock.Size.Width
                             - ContainingBlock.ActualPaddingLeft - ContainingBlock.ActualPaddingRight
                             - ContainingBlock.ActualBorderLeftWidth - ContainingBlock.ActualBorderRightWidth
                             - ActualMarginLeft - ActualMarginRight - ActualBorderLeftWidth - ActualBorderRightWidth;

            //Check width if not auto
            if (Width != CssConstants.Auto && !string.IsNullOrEmpty(Width))
            {
                width = CssValueParser.ParseLength(Width, width, this);
            }

            if (width < minwidth || width >= 9999)
            {
                width = minwidth;
            }

            float height = ActualHeight;

            if (height < 1)
            {
                height = Size.Height + ActualBorderTopWidth + ActualBorderBottomWidth;
            }
            if (height < 1)
            {
                height = 2;
            }
            if (height <= 2 && ActualBorderTopWidth < 1 && ActualBorderBottomWidth < 1)
            {
                BorderTopStyle    = BorderBottomStyle = CssConstants.Solid;
                BorderTopWidth    = "1px";
                BorderBottomWidth = "1px";
            }

            Size = new SizeF(width, height);

            ActualBottom = Location.Y + ActualPaddingTop + ActualPaddingBottom + height;
        }
Example #2
0
        /// <summary>
        /// Measures the bounds of box and children, recursively.<br/>
        /// Performs layout of the DOM structure creating lines by set bounds restrictions.
        /// </summary>
        /// <param name="g">Device context to use</param>
        protected override void PerformLayoutImp(RGraphics g)
        {
            if (this.Display == CssConstants.None)
            {
                return;
            }

            this.RectanglesReset();

            var    prevSibling = DomUtils.GetPreviousSibling(this);
            double left        = this.ContainingBlock.Location.X + this.ContainingBlock.ActualPaddingLeft + this.ActualMarginLeft + this.ContainingBlock.ActualBorderLeftWidth;
            double top         = (prevSibling == null && this.ParentBox != null ? this.ParentBox.ClientTop : this.ParentBox == null ? this.Location.Y : 0) + this.MarginTopCollapse(prevSibling) + (prevSibling != null ? prevSibling.ActualBottom + prevSibling.ActualBorderBottomWidth : 0);

            this.Location     = new RPoint(left, top);
            this.ActualBottom = top;

            //width at 100% (or auto)
            double minwidth = this.GetMinimumWidth();
            double width    = this.ContainingBlock.Size.Width
                              - this.ContainingBlock.ActualPaddingLeft - this.ContainingBlock.ActualPaddingRight
                              - this.ContainingBlock.ActualBorderLeftWidth - this.ContainingBlock.ActualBorderRightWidth
                              - this.ActualMarginLeft - this.ActualMarginRight - this.ActualBorderLeftWidth - this.ActualBorderRightWidth;

            //Check width if not auto
            if (this.Width != CssConstants.Auto && !string.IsNullOrEmpty(this.Width))
            {
                width = CssValueParser.ParseLength(this.Width, width, this);
            }

            if (width < minwidth || width >= 9999)
            {
                width = minwidth;
            }

            double height = this.ActualHeight;

            if (height < 1)
            {
                height = this.Size.Height + this.ActualBorderTopWidth + this.ActualBorderBottomWidth;
            }
            if (height < 1)
            {
                height = 2;
            }
            if (height <= 2 && this.ActualBorderTopWidth < 1 && this.ActualBorderBottomWidth < 1)
            {
                this.BorderTopStyle    = this.BorderBottomStyle = CssConstants.Solid;
                this.BorderTopWidth    = "1px";
                this.BorderBottomWidth = "1px";
            }

            this.Size = new RSize(width, height);

            this.ActualBottom = this.Location.Y + this.ActualPaddingTop + this.ActualPaddingBottom + height;
        }
Example #3
0
        /// <summary>
        /// Measures the bounds of box and children, recursively.<br/>
        /// Performs layout of the DOM structure creating lines by set bounds restrictions.
        /// </summary>
        /// <param name="g">Device context to use</param>
        private void MeasureBoundsImp(Graphics g)
        {
            if (Display == CssConstants.None)
            {
                return;
            }

            RectanglesReset();

            MeasureWordsSize(g);

            if (Display == CssConstants.Block ||
                Display == CssConstants.ListItem ||
                Display == CssConstants.Table ||
                Display == CssConstants.InlineTable ||
                Display == CssConstants.TableCell ||
                Display == CssConstants.None)
            {
                if (Display != CssConstants.TableCell)
                {
                    var   prevSibling = DomUtils.GetPreviousSibling(this);
                    float left        = ContainingBlock.Location.X + ContainingBlock.ActualPaddingLeft + ActualMarginLeft + ContainingBlock.ActualBorderLeftWidth;
                    float top         = (prevSibling == null && ParentBox != null ? ParentBox.ClientTop : ParentBox == null ? Location.Y : 0) + MarginTopCollapse(prevSibling) + (prevSibling != null ? prevSibling.ActualBottom + prevSibling.ActualBorderBottomWidth : 0);
                    Location     = new PointF(left, top);
                    ActualBottom = top;
                }

                // Because their width and height are set by CssTable
                if (Display != CssConstants.TableCell && Display != CssConstants.Table)
                {
                    //width at 100% (or auto)
                    float minwidth = GetMinimumWidth();
                    float width    = ContainingBlock.Size.Width
                                     - ContainingBlock.ActualPaddingLeft - ContainingBlock.ActualPaddingRight
                                     - ContainingBlock.ActualBorderLeftWidth - ContainingBlock.ActualBorderRightWidth
                                     - ActualMarginLeft - ActualMarginRight - ActualBorderLeftWidth - ActualBorderRightWidth;

                    //Check width if not auto
                    if (Width != CssConstants.Auto && !string.IsNullOrEmpty(Width))
                    {
                        width = CssValueParser.ParseLength(Width, width, this);
                    }

                    if (width < minwidth || width >= 9999)
                    {
                        width = minwidth;
                    }

                    Size = new SizeF(width, Size.Height);
                }

                //If we're talking about a table here..
                if (Display == CssConstants.Table || Display == CssConstants.InlineTable)
                {
                    new CssTable(this, g);
                }
                else
                {
                    //If there's just inlines, create LineBoxes
                    if (DomUtils.ContainsInlinesOnly(this))
                    {
                        ActualBottom = Location.Y;
                        CssLayoutEngine.CreateLineBoxes(g, this); //This will automatically set the bottom of this block
                    }
                    else if (_boxes.Count > 0)
                    {
                        foreach (var childBox in Boxes)
                        {
                            childBox.MeasureBoundsImp(g);
                        }
                        ActualBottom = MarginBottomCollapse();
                    }
                }
            }

            if (HtmlContainer != null)
            {
                HtmlContainer.ActualSize = new SizeF(Math.Max(HtmlContainer.ActualSize.Width, Size.Width < 9999 ? Size.Width : 0), Math.Max(HtmlContainer.ActualSize.Height, Size.Height));
            }
        }