public void Reset()
        {
            _latestFloatingContext = null;
            _totalContexts.Clear();
            _floatingContexts.Clear();
#if DEBUG
            _dbugDic1.Clear();
#endif
        }
Beispiel #2
0
 public void PushContainingBlock(CssBox box)
 {
     if (latestFloatingContext == null)
     {
         latestFloatingContext = new FloatingContext(box);
         totalContext.Add(latestFloatingContext);
     }
     else
     {
         if (box.Float != Css.CssFloat.None)
         {
             latestFloatingContext = new FloatingContext(box);
             totalContext.Add(latestFloatingContext);
         }
     }
     floatingContexts.Add(latestFloatingContext);
 }
 public void PopContainingBlock()
 {
     switch (floatingContexts.Count)
     {
         case 0:
             latestFloatingContext = null;
             return;
         case 1:
             floatingContexts.Clear();
             latestFloatingContext = null;
             break;
         default:
             floatingContexts.RemoveAt(floatingContexts.Count - 1);
             latestFloatingContext = floatingContexts[floatingContexts.Count - 1];
             break;
     }
 }
 public void PushContainingBlock(CssBox box)
 {
     if (latestFloatingContext == null)
     {
         latestFloatingContext = new FloatingContext(box);
         totalContext.Add(latestFloatingContext);
     }
     else
     {
         if (box.Float != Css.CssFloat.None)
         {
             latestFloatingContext = new FloatingContext(box);
             totalContext.Add(latestFloatingContext);
         }
     }
     floatingContexts.Add(latestFloatingContext);
 }
Beispiel #5
0
        public void PopContainingBlock()
        {
            switch (floatingContexts.Count)
            {
            case 0:
                latestFloatingContext = null;
                return;

            case 1:
                floatingContexts.Clear();
                latestFloatingContext = null;
                break;

            default:
                floatingContexts.RemoveAt(floatingContexts.Count - 1);
                latestFloatingContext = floatingContexts[floatingContexts.Count - 1];
                break;
            }
        }
 public void PushContainingBlock(CssBox box)
 {
     if (_latestFloatingContext == null)
     {
         if (box.IsBody)
         {
             _latestFloatingContext = new FloatingContext(box);
             _totalContexts.Add(_latestFloatingContext);
         }
     }
     else
     {
         if (box.Float != Css.CssFloat.None)
         {
             _latestFloatingContext = new FloatingContext(box);
             _totalContexts.Add(_latestFloatingContext);
         }
     }
     if (_latestFloatingContext != null)
     {
         _floatingContexts.Add(_latestFloatingContext);
     }
 }
Beispiel #7
0
        public void PerformLayout(LayoutVisitor lay)
        {
            if (this._rootBox == null)
            {
                return;
            }
            //-----------------------
            //reset
            _actualWidth = _actualHeight = 0;
            // if width is not restricted we set it to large value to get the actual later
            _rootBox.SetLocation(0, 0);
            _rootBox.SetVisualSize(this._maxWidth > 0 ? this._maxWidth : MAX_WIDTH, 0);
            CssBox.ValidateComputeValues(_rootBox);
            //-----------------------
            //LayoutVisitor layoutArgs = new LayoutVisitor(this.GraphicsPlatform, this);
            lay.PushContaingBlock(_rootBox);
            //-----------------------

            _rootBox.PerformLayout(lay);
            if (this._maxWidth <= 0.1)
            {
                // in case the width is not restricted we need to double layout, first will find the width so second can layout by it (center alignment)
                _rootBox.SetVisualWidth((int)Math.Ceiling(this._actualWidth));
                _actualWidth = _actualHeight = 0;
                _rootBox.PerformLayout(lay);
            }
            lay.PopContainingBlock();
            //-----------------------
            //TODO: review here again
            FloatingContextStack   floatStack    = lay.GetFloatingContextStack();
            List <FloatingContext> totalContexts = floatStack.GetTotalContexts();
            int j = totalContexts.Count;

            for (int i = 0; i < j; ++i)
            {
                FloatingContext floatingContext = totalContexts[i];
                int             floatBoxCount   = floatingContext.FloatBoxCount;
                if (floatBoxCount == 0)
                {
                    continue;
                }


                CssBox floatingOwner = floatingContext.Owner;
                float  rfx, rfy;
                floatingOwner.GetGlobalLocation(out rfx, out rfy);
                CssBox prevParent = null;
                //TODO: review here again
                float extraAdjustX = 0; //temp fixed
                for (int n = 0; n < floatBoxCount; ++n)
                {
                    float  bfx, bfy;
                    CssBox box = floatingContext.GetBox(n);
                    box.GetGlobalLocation(out bfx, out bfy);
                    //diff
                    float nx = bfx - rfx;
                    float ny = bfy - rfy;
                    if (prevParent != null && prevParent != box.ParentBox)
                    {
                        if (n > 0)
                        {
                            CssBox prevFloatChild = floatingContext.GetBox(n - 1);
                            //TODO: review here again
                            //temp fix
                            extraAdjustX = prevFloatChild.ActualMarginRight + box.ActualMarginLeft;
                            ny          += box.ActualMarginTop;
                        }
                    }
                    box.SetLocation(nx + extraAdjustX, ny);
                    prevParent = box.ParentBox;
                    floatingOwner.AppendToAbsoluteLayer(box);
                }
            }

            OnLayoutFinished();
            //-----------------------
            unchecked { layoutVersion++; }
            //-----------------------
        }