Skip to content

Commit

Permalink
Merge branch 'css_float' into box_dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
prepare committed May 8, 2015
2 parents 3ccc692 + 67e331c commit b058d0a
Show file tree
Hide file tree
Showing 21 changed files with 570 additions and 118 deletions.
8 changes: 8 additions & 0 deletions Source/HtmlRenderer.Demo/Samples/Basic/54_float1.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p style='background-color:yellow;padding:2px'>a<span style="background-color:blue;float:right">b</span>c</p>
</body>
</html>
12 changes: 12 additions & 0 deletions Source/HtmlRenderer.Demo/Samples/Basic/55_float2.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>

<p style="background-color:yellow;float:left;">X1 yellow</p>
<p style="background-color:lime;float:right;">X2 lime</p>
<p style="background-color:red;">A1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 redA1 red</p>
<p style="background-color:blue;float:left">A2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 blueA2 </p>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,7 @@ BoxSpec SearchUpBoxSpec(CssTemplateKey templateKey)
BoxSpec boxTemplate = null;
if (boxTemplate != null)
{
if (boxTemplate.versionId > currentBoxSpec.versionId)
{
BoxSpec.CloneAllStyles(currentBoxSpec, boxTemplate);
}
else
{
BoxSpec.CloneAllStyles(currentBoxSpec, boxTemplate);
}
//return boxTemplate;
BoxSpec.CloneAllStyles(currentBoxSpec, boxTemplate);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void SetPropertyValue(BoxSpec spec, WebDom.CssPropertyDeclaration decl)
case WellknownCssPropertyName.BoxSizing:
spec.BoxSizing = UserMapUtil.GetBoxSizing(cssValue);
break;

case WellknownCssPropertyName.BoxShadow:
SetBoxShadow(spec, decl);
break;
Expand Down
6 changes: 3 additions & 3 deletions Source/LayoutFarm.HtmlRenderer/1_Css/BoxSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ namespace LayoutFarm.Css
public sealed partial class BoxSpec
{

static long totalVersion;

bool _freezed;
public readonly long versionId = totalVersion++;

//public readonly long versionId = totalVersion++;
//static long totalVersion;
//==========================================================
#region css values Inherit From Parent (by default)
//inherit from parent by default
Expand Down
30 changes: 17 additions & 13 deletions Source/LayoutFarm.HtmlRenderer/2_Boxes/1_CoreBox/BoxVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ namespace LayoutFarm.HtmlBoxes
public abstract class BoxVisitor
{
Stack<CssBox> containgBlockStack = new Stack<CssBox>();
CssBox latestContaingBlock = null;

CssBox latestContaingBlock = null;
float globalXOffset;
float globalYOffset;


internal void PushContaingBlock(CssBox box)
{
{
//enter new containing block
if (box != latestContaingBlock)
{
this.globalXOffset += box.LocalX;
Expand All @@ -23,16 +25,7 @@ internal void PushContaingBlock(CssBox box)
this.containgBlockStack.Push(box);
this.latestContaingBlock = box;
}
protected virtual void OnPushDifferentContainingBlock(CssBox box)
{
}
protected virtual void OnPopDifferentContaingBlock(CssBox box)
{
}
internal CssBox LatestContainingBlock
{
get { return this.latestContaingBlock; }
}

internal void PopContainingBlock()
{
switch (this.containgBlockStack.Count)
Expand Down Expand Up @@ -75,6 +68,17 @@ internal float ContainerBlockGlobalY
get { return this.globalYOffset; }
}
//-----------------------------------------
protected virtual void OnPushDifferentContainingBlock(CssBox box)
{
}
protected virtual void OnPopDifferentContaingBlock(CssBox box)
{
}
internal CssBox LatestContainingBlock
{
get { return this.latestContaingBlock; }
}

}

}
16 changes: 11 additions & 5 deletions Source/LayoutFarm.HtmlRenderer/2_Boxes/1_CoreBox/CssBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public partial class CssBox
{

readonly Css.BoxSpec _myspec;

object _controller;
IRootGraphics rootgfx;

#if DEBUG
public int dbugMark1;
public readonly int __aa_dbugId = dbugTotalId++;
static int dbugTotalId;
public int dbugMark;
#endif
#endif
public CssBox(BoxSpec spec, IRootGraphics rootgfx)
{
this.rootgfx = rootgfx;
Expand Down Expand Up @@ -87,15 +87,15 @@ public CssBox(BoxSpec spec, IRootGraphics rootgfx, CssDisplay displayType)
//assign spec
this._boxCompactFlags |= BoxFlags.DONT_CHANGE_DISPLAY_TYPE;
this._cssDisplay = displayType;

this._myspec = spec;
//----------------------------
EvaluateSpec(spec);
ChangeDisplayType(this, _myspec.CssDisplay);
}
public void SetController(object controller)
{
this._controller = controller;
}
}
public IRootGraphics RootGfx
{
get { return this.rootgfx; }
Expand All @@ -120,7 +120,13 @@ public CssBox GetTopRootCssBox()
return topmost;
}



internal virtual bool JustTempContainer
{
//temp fixed for FloatBox
//TODO: review here again
get { return false; }
}
/// <summary>
/// Is the box is of "br" element.
/// </summary>
Expand Down
14 changes: 11 additions & 3 deletions Source/LayoutFarm.HtmlRenderer/2_Boxes/1_CoreBox/CssBox_Fields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,24 @@ partial class CssBox


/// <summary>
/// absolute position layer
/// absolute position layer
/// </summary>
CssBoxCollection _absPosLayer;
CssBlockRun justBlockRun;

//----------------------------------------------------
//only in condition 3
char[] _buffer;
//----------------------------------------------------
CssBoxDecorator decorator;
bool mayHasViewport;
bool isOutOfFlowBox;

internal bool IsOutOfFlowBox
{
get { return this.isOutOfFlowBox; }
set { this.isOutOfFlowBox = value; }
}

internal int RunCount
{
Expand Down Expand Up @@ -293,7 +300,8 @@ public void AppendToAbsoluteLayer(CssBox box)
{

}
}
}

//-------------------------------------
internal void ResetLineBoxes()
{
Expand Down
43 changes: 33 additions & 10 deletions Source/LayoutFarm.HtmlRenderer/2_Boxes/1_CoreBox/CssBox_Paint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ public virtual void InvalidateGraphics(Rectangle clientArea)
}
public void Paint(PaintVisitor p)
{



#if DEBUG
dbugCounter.dbugBoxPaintCount++;
#endif
Expand Down Expand Up @@ -104,11 +101,12 @@ protected virtual void PaintImp(PaintVisitor p)
#if DEBUG
p.dbugEnterNewContext(this, PaintVisitor.PaintVisitorContextName.Init);
#endif

//-----------------------------------------------
bool hasPrevClip = false;
RectangleF prevClip = RectangleF.Empty;


p.EnterNewLatePaintContext();
//---------------------------------------------
//if (display != Css.CssDisplay.Inline ||
// this.Position == Css.CssPosition.Absolute ||
Expand Down Expand Up @@ -191,19 +189,25 @@ protected virtual void PaintImp(PaintVisitor p)
if (this.HasContainingBlockProperty)
{
p.PushContaingBlock(this);

int ox = p.CanvasOriginX;
int oy = p.CanvasOriginY;

var node = this._aa_boxes.GetFirstLinkedNode();
while (node != null)
{

CssBox b = node.Value;
if (b.CssDisplay == Css.CssDisplay.None)
{
node = node.Next;
continue;
}
else if (b.IsOutOfFlowBox)
{
//
p.AddToLatePaintList(b);
node = node.Next;
continue;
}
//move to left-top of client box
p.SetCanvasOrigin(ox + (int)b.LocalX, oy + (int)b.LocalY);
if (b.decorator != null)
Expand Down Expand Up @@ -249,9 +253,7 @@ protected virtual void PaintImp(PaintVisitor p)
b.Paint(p);
node = node.Next;
}

p.SetCanvasOrigin(ox, oy);

}
}
//------------------------------------------
Expand All @@ -263,9 +265,7 @@ protected virtual void PaintImp(PaintVisitor p)

if (this.HasAbsoluteLayer)
{

p.PushContaingBlock(this);

int ox = p.CanvasOriginX;
int oy = p.CanvasOriginY;
var node = this._absPosLayer.GetFirstLinkedNode();
Expand All @@ -284,7 +284,30 @@ protected virtual void PaintImp(PaintVisitor p)
p.SetCanvasOrigin(ox, oy);
p.PopContainingBlock();
}
if (p.LatePaintItemCount > 0)
{
//clear late paint item
p.PushContaingBlock(this);
int j = p.LatePaintItemCount;
int ox = p.CanvasOriginX;
int oy = p.CanvasOriginY;

for (int i = 0; i < j; ++i)
{
CssBox box = p.GetLatePaintItem(i);

if (box.CssDisplay == Css.CssDisplay.None)
{
continue;
}
p.SetCanvasOrigin(ox + (int)box.LocalX, oy + (int)box.LocalY);
box.Paint(p);
p.SetCanvasOrigin(ox, oy);
}
p.PopContainingBlock();
}
p.ExitCurrentLatePaintContext();

//must! ,
if (hasPrevClip)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ public float LocalBottom
/// <param name="localY"></param>
public void SetLocation(float localX, float localY)
{

this._localX = localX;
this._localY = localY;
this._boxCompactFlags |= BoxFlags.HAS_ASSIGNED_LOCATION;
Expand Down Expand Up @@ -395,33 +394,37 @@ internal bool FreezeWidth
}
public void SetSize(float width, float height)
{

if (!this.FreezeWidth)
{
this._sizeWidth = width;
}
this._sizeHeight = height;

this._sizeHeight = height;
}
public void SetHeight(float height)
{

this._sizeHeight = height;
}

public void SetWidth(float width)
{
if (!this.FreezeWidth)
{
this._sizeWidth = width;
}
}
}
/// <summary>
/// presentation width (border+ padding+ content), for clip area
/// </summary>
public float SizeWidth
{
get
{
return this._sizeWidth;
}
}
/// <summary>
/// presentaion height (border+padding+ content), for clip area
/// </summary>
public float SizeHeight
{
get
Expand Down Expand Up @@ -836,10 +839,9 @@ public float InnerContentWidth
{
get { return this._innerContentW; }
internal set
{
{
this._innerContentW = value;
}

}
}
/// <summary>
/// inner content height
Expand All @@ -848,7 +850,7 @@ public float InnerContentHeight
{
get { return this._innerContentH; }
internal set
{
{
this._innerContentH = value;
}
}
Expand Down

0 comments on commit b058d0a

Please sign in to comment.