From 09a9d2280ca6e7680ff25937ea0803f1ef7c633b Mon Sep 17 00:00:00 2001 From: Andrey Ushakov Date: Wed, 4 May 2016 08:55:24 +0300 Subject: [PATCH 1/4] Show table headers on every page in generated PDF --- .../Common/HtmlRenderer.Demo.Common.csproj | 3 + .../36.Table's headers on every page.htm | 1656 +++++++++++++++++ Source/HtmlRenderer/Core/Dom/CssBox.cs | 8 +- Source/HtmlRenderer/Core/Dom/CssBoxCopy.cs | 34 + .../Core/Dom/CssLayoutEngineTable.cs | 90 +- Source/HtmlRenderer/Core/Parse/CssParser.cs | 10 + Source/HtmlRenderer/HtmlRenderer.csproj | 1 + 7 files changed, 1796 insertions(+), 6 deletions(-) create mode 100644 Source/Demo/Common/TestSamples/36.Table's headers on every page.htm create mode 100644 Source/HtmlRenderer/Core/Dom/CssBoxCopy.cs diff --git a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj index 7413cc397..fe647a286 100644 --- a/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj +++ b/Source/Demo/Common/HtmlRenderer.Demo.Common.csproj @@ -167,6 +167,9 @@ + + + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/HtmlRenderer/Core/Dom/CssBox.cs b/Source/HtmlRenderer/Core/Dom/CssBox.cs index 028415fb0..464595acf 100644 --- a/Source/HtmlRenderer/Core/Dom/CssBox.cs +++ b/Source/HtmlRenderer/Core/Dom/CssBox.cs @@ -1341,7 +1341,7 @@ protected void PaintBackground(RGraphics g, RRect rect, bool isFirst, bool isLas RGraphicsPath roundrect = null; if (IsRounded) { - roundrect = RenderUtils.GetRoundRect(g, rect, ActualCornerNw, ActualCornerNe, ActualCornerSe, ActualCornerSw); + roundrect = RenderUtils.GetRoundRect(g, rect, ActualBorderTLRadius, ActualBorderTRRadius, ActualBorderBRRadius, ActualBorderBLRadius); } Object prevMode = null; @@ -1356,7 +1356,7 @@ protected void PaintBackground(RGraphics g, RRect rect, bool isFirst, bool isLas } else { - g.DrawRectangle(brush, Math.Ceiling(rect.X), Math.Ceiling(rect.Y), rect.Width, rect.Height); + g.DrawRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height); } g.ReturnPreviousSmoothingMode(prevMode); @@ -1446,7 +1446,7 @@ protected void PaintDecoration(RGraphics g, RRect rectangle, bool isFirst, bool double y = 0f; if (TextDecoration == CssConstants.Underline) { - y = Math.Round(rectangle.Top + ActualFont.UnderlineOffset); + y = rectangle.Top + ActualFont.UnderlineOffset; } else if (TextDecoration == CssConstants.LineThrough) { diff --git a/Source/HtmlRenderer/Core/Dom/CssBoxProperties.cs b/Source/HtmlRenderer/Core/Dom/CssBoxProperties.cs index 7abfb53ed..a658085a4 100644 --- a/Source/HtmlRenderer/Core/Dom/CssBoxProperties.cs +++ b/Source/HtmlRenderer/Core/Dom/CssBoxProperties.cs @@ -54,11 +54,11 @@ internal abstract class CssBoxProperties private string _bottom; private string _color = "black"; private string _content = "normal"; - private string _cornerNwRadius = "0"; - private string _cornerNeRadius = "0"; - private string _cornerSeRadius = "0"; - private string _cornerSwRadius = "0"; - private string _cornerRadius = "0"; + private string _borderTLRadius = "0"; + private string _borderTRRadius = "0"; + private string _borderBRRadius = "0"; + private string _borderBLRadius = "0"; + private string _borderRadius = "0"; private string _emptyCells = "show"; private string _direction = "ltr"; private string _display = "inline"; @@ -114,10 +114,10 @@ internal abstract class CssBoxProperties /// private RSize _size; - private double _actualCornerNw = double.NaN; - private double _actualCornerNe = double.NaN; - private double _actualCornerSw = double.NaN; - private double _actualCornerSe = double.NaN; + private double _actualBorderTLRadius = double.NaN; + private double _actualBorderTRRadius = double.NaN; + private double _actualBorderBLRadius = double.NaN; + private double _actualBorderBRRadius = double.NaN; private RColor _actualColor = RColor.Empty; private double _actualBackgroundGradientAngle = double.NaN; private double _actualHeight = double.NaN; @@ -274,9 +274,9 @@ public string BorderCollapse set { _borderCollapse = value; } } - public string CornerRadius + public string BorderRadius { - get { return _cornerRadius; } + get { return _borderRadius; } set { MatchCollection r = RegexParserUtils.Match(RegexParserUtils.CssLength, value); @@ -284,56 +284,56 @@ public string CornerRadius switch (r.Count) { case 1: - CornerNeRadius = r[0].Value; - CornerNwRadius = r[0].Value; - CornerSeRadius = r[0].Value; - CornerSwRadius = r[0].Value; + BorderTRRadius = r[0].Value; + BorderTLRadius = r[0].Value; + BorderBRRadius = r[0].Value; + BorderBLRadius = r[0].Value; break; case 2: - CornerNeRadius = r[0].Value; - CornerNwRadius = r[0].Value; - CornerSeRadius = r[1].Value; - CornerSwRadius = r[1].Value; + BorderTRRadius = r[0].Value; + BorderTLRadius = r[0].Value; + BorderBRRadius = r[1].Value; + BorderBLRadius = r[1].Value; break; case 3: - CornerNeRadius = r[0].Value; - CornerNwRadius = r[1].Value; - CornerSeRadius = r[2].Value; + BorderTRRadius = r[0].Value; + BorderTLRadius = r[1].Value; + BorderBRRadius = r[2].Value; break; case 4: - CornerNeRadius = r[0].Value; - CornerNwRadius = r[1].Value; - CornerSeRadius = r[2].Value; - CornerSwRadius = r[3].Value; + BorderTRRadius = r[0].Value; + BorderTLRadius = r[1].Value; + BorderBRRadius = r[2].Value; + BorderBLRadius = r[3].Value; break; } - _cornerRadius = value; + _borderRadius = value; } } - public string CornerNwRadius + public string BorderTLRadius { - get { return _cornerNwRadius; } - set { _cornerNwRadius = value; } + get { return _borderTLRadius; } + set { _borderTLRadius = value; } } - public string CornerNeRadius + public string BorderTRRadius { - get { return _cornerNeRadius; } - set { _cornerNeRadius = value; } + get { return _borderTRRadius; } + set { _borderTRRadius = value; } } - public string CornerSeRadius + public string BorderBRRadius { - get { return _cornerSeRadius; } - set { _cornerSeRadius = value; } + get { return _borderBRRadius; } + set { _borderBRRadius = value; } } - public string CornerSwRadius + public string BorderBLRadius { - get { return _cornerSwRadius; } - set { _cornerSwRadius = value; } + get { return _borderBLRadius; } + set { _borderBLRadius = value; } } public string MarginBottom @@ -1105,62 +1105,62 @@ public RColor ActualBorderRightColor } /// - /// Gets the actual length of the north west corner + /// Gets the actual top left border radius /// - public double ActualCornerNw + public double ActualBorderTLRadius { get { - if (double.IsNaN(_actualCornerNw)) + if (double.IsNaN(_actualBorderTLRadius)) { - _actualCornerNw = CssValueParser.ParseLength(CornerNwRadius, 0, this); + _actualBorderTLRadius = CssValueParser.ParseLength(BorderTLRadius, 0, this); } - return _actualCornerNw; + return _actualBorderTLRadius; } } /// - /// Gets the actual length of the north east corner + /// Gets the actual top right border radius /// - public double ActualCornerNe + public double ActualBorderTRRadius { get { - if (double.IsNaN(_actualCornerNe)) + if (double.IsNaN(_actualBorderTRRadius)) { - _actualCornerNe = CssValueParser.ParseLength(CornerNeRadius, 0, this); + _actualBorderTRRadius = CssValueParser.ParseLength(BorderTRRadius, 0, this); } - return _actualCornerNe; + return _actualBorderTRRadius; } } /// - /// Gets the actual length of the south east corner + /// Gets the actual bottom right border radius /// - public double ActualCornerSe + public double ActualBorderBRRadius { get { - if (double.IsNaN(_actualCornerSe)) + if (double.IsNaN(_actualBorderBRRadius)) { - _actualCornerSe = CssValueParser.ParseLength(CornerSeRadius, 0, this); + _actualBorderBRRadius = CssValueParser.ParseLength(BorderBRRadius, 0, this); } - return _actualCornerSe; + return _actualBorderBRRadius; } } /// - /// Gets the actual length of the south west corner + /// Gets the actual bottom left border radius /// - public double ActualCornerSw + public double ActualBorderBLRadius { get { - if (double.IsNaN(_actualCornerSw)) + if (double.IsNaN(_actualBorderBLRadius)) { - _actualCornerSw = CssValueParser.ParseLength(CornerSwRadius, 0, this); + _actualBorderBLRadius = CssValueParser.ParseLength(BorderBLRadius, 0, this); } - return _actualCornerSw; + return _actualBorderBLRadius; } } @@ -1169,7 +1169,7 @@ public double ActualCornerSw /// public bool IsRounded { - get { return ActualCornerNe > 0f || ActualCornerNw > 0f || ActualCornerSe > 0f || ActualCornerSw > 0f; } + get { return ActualBorderTRRadius > 0f || ActualBorderTLRadius > 0f || ActualBorderBRRadius > 0f || ActualBorderBLRadius > 0f; } } /// @@ -1534,11 +1534,11 @@ protected void InheritStyle(CssBox p, bool everything) _borderBottomStyle = p._borderBottomStyle; _borderLeftStyle = p._borderLeftStyle; _bottom = p._bottom; - _cornerNwRadius = p._cornerNwRadius; - _cornerNeRadius = p._cornerNeRadius; - _cornerSeRadius = p._cornerSeRadius; - _cornerSwRadius = p._cornerSwRadius; - _cornerRadius = p._cornerRadius; + _borderTLRadius = p._borderTLRadius; + _borderTRRadius = p._borderTRRadius; + _borderBRRadius = p._borderBRRadius; + _borderBLRadius = p._borderBLRadius; + _borderRadius = p._borderRadius; _display = p._display; _float = p._float; _height = p._height; diff --git a/Source/HtmlRenderer/Core/Handlers/BordersDrawHandler.cs b/Source/HtmlRenderer/Core/Handlers/BordersDrawHandler.cs index b20c331cb..f0740c43c 100644 --- a/Source/HtmlRenderer/Core/Handlers/BordersDrawHandler.cs +++ b/Source/HtmlRenderer/Core/Handlers/BordersDrawHandler.cs @@ -126,16 +126,16 @@ private static void DrawBorder(Border border, CssBox box, RGraphics g, RRect rec switch (border) { case Border.Top: - g.DrawLine(pen, Math.Ceiling(rect.Left), rect.Top + box.ActualBorderTopWidth / 2, rect.Right - 1, rect.Top + box.ActualBorderTopWidth / 2); + g.DrawLine(pen, rect.Left, rect.Top + box.ActualBorderTopWidth / 2, rect.Right, rect.Top + box.ActualBorderTopWidth / 2); break; case Border.Left: - g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, Math.Ceiling(rect.Top), rect.Left + box.ActualBorderLeftWidth / 2, Math.Floor(rect.Bottom)); + g.DrawLine(pen, rect.Left + box.ActualBorderLeftWidth / 2, rect.Top, rect.Left + box.ActualBorderLeftWidth / 2, rect.Bottom); break; case Border.Bottom: - g.DrawLine(pen, Math.Ceiling(rect.Left), rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right - 1, rect.Bottom - box.ActualBorderBottomWidth / 2); + g.DrawLine(pen, rect.Left, rect.Bottom - box.ActualBorderBottomWidth / 2, rect.Right, rect.Bottom - box.ActualBorderBottomWidth / 2); break; case Border.Right: - g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, Math.Ceiling(rect.Top), rect.Right - box.ActualBorderRightWidth / 2, Math.Floor(rect.Bottom)); + g.DrawLine(pen, rect.Right - box.ActualBorderRightWidth / 2, rect.Top, rect.Right - box.ActualBorderRightWidth / 2, rect.Bottom); break; } } @@ -206,69 +206,69 @@ private static RGraphicsPath GetRoundedBorderPath(RGraphics g, Border border, Cs switch (border) { case Border.Top: - if (b.ActualCornerNw > 0 || b.ActualCornerNe > 0) + if (b.ActualBorderTLRadius > 0 || b.ActualBorderTRRadius > 0) { path = g.GetGraphicsPath(); - path.Start(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualCornerNw); + path.Start(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualBorderTLRadius); - if (b.ActualCornerNw > 0) - path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2 + b.ActualCornerNw, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNw, RGraphicsPath.Corner.TopLeft); + if (b.ActualBorderTLRadius > 0) + path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2 + b.ActualBorderTLRadius, r.Top + b.ActualBorderTopWidth / 2, b.ActualBorderTLRadius, RGraphicsPath.Corner.TopLeft); - path.LineTo(r.Right - b.ActualBorderRightWidth / 2 - b.ActualCornerNe, r.Top + b.ActualBorderTopWidth / 2); + path.LineTo(r.Right - b.ActualBorderRightWidth / 2 - b.ActualBorderTRRadius, r.Top + b.ActualBorderTopWidth / 2); - if (b.ActualCornerNe > 0) - path.ArcTo(r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualCornerNe, b.ActualCornerNe, RGraphicsPath.Corner.TopRight); + if (b.ActualBorderTRRadius > 0) + path.ArcTo(r.Right - b.ActualBorderRightWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualBorderTRRadius, b.ActualBorderTRRadius, RGraphicsPath.Corner.TopRight); } break; case Border.Bottom: - if (b.ActualCornerSw > 0 || b.ActualCornerSe > 0) + if (b.ActualBorderBLRadius > 0 || b.ActualBorderBRRadius > 0) { path = g.GetGraphicsPath(); - path.Start(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualCornerSe); + path.Start(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualBorderBRRadius); - if (b.ActualCornerSe > 0) - path.ArcTo(r.Right - b.ActualBorderRightWidth / 2 - b.ActualCornerSe, r.Bottom - b.ActualBorderBottomWidth / 2, b.ActualCornerSe, RGraphicsPath.Corner.BottomRight); + if (b.ActualBorderBRRadius > 0) + path.ArcTo(r.Right - b.ActualBorderRightWidth / 2 - b.ActualBorderBRRadius, r.Bottom - b.ActualBorderBottomWidth / 2, b.ActualBorderBRRadius, RGraphicsPath.Corner.BottomRight); - path.LineTo(r.Left + b.ActualBorderLeftWidth / 2 + b.ActualCornerSw, r.Bottom - b.ActualBorderBottomWidth / 2); + path.LineTo(r.Left + b.ActualBorderLeftWidth / 2 + b.ActualBorderBLRadius, r.Bottom - b.ActualBorderBottomWidth / 2); - if (b.ActualCornerSw > 0) - path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualCornerSw, b.ActualCornerSw, RGraphicsPath.Corner.BottomLeft); + if (b.ActualBorderBLRadius > 0) + path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualBorderBLRadius, b.ActualBorderBLRadius, RGraphicsPath.Corner.BottomLeft); } break; case Border.Right: - if (b.ActualCornerNe > 0 || b.ActualCornerSe > 0) + if (b.ActualBorderTRRadius > 0 || b.ActualBorderBRRadius > 0) { path = g.GetGraphicsPath(); bool noTop = b.BorderTopStyle == CssConstants.None || b.BorderTopStyle == CssConstants.Hidden; bool noBottom = b.BorderBottomStyle == CssConstants.None || b.BorderBottomStyle == CssConstants.Hidden; - path.Start(r.Right - b.ActualBorderRightWidth / 2 - (noTop ? b.ActualCornerNe : 0), r.Top + b.ActualBorderTopWidth / 2 + (noTop ? 0 : b.ActualCornerNe)); + path.Start(r.Right - b.ActualBorderRightWidth / 2 - (noTop ? b.ActualBorderTRRadius : 0), r.Top + b.ActualBorderTopWidth / 2 + (noTop ? 0 : b.ActualBorderTRRadius)); - if (b.ActualCornerNe > 0 && noTop) - path.ArcTo(r.Right - b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualCornerNe, b.ActualCornerNe, RGraphicsPath.Corner.TopRight); + if (b.ActualBorderTRRadius > 0 && noTop) + path.ArcTo(r.Right - b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualBorderTRRadius, b.ActualBorderTRRadius, RGraphicsPath.Corner.TopRight); - path.LineTo(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualCornerSe); + path.LineTo(r.Right - b.ActualBorderRightWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualBorderBRRadius); - if (b.ActualCornerSe > 0 && noBottom) - path.ArcTo(r.Right - b.ActualBorderRightWidth / 2 - b.ActualCornerSe, r.Bottom - b.ActualBorderBottomWidth / 2, b.ActualCornerSe, RGraphicsPath.Corner.BottomRight); + if (b.ActualBorderBRRadius > 0 && noBottom) + path.ArcTo(r.Right - b.ActualBorderRightWidth / 2 - b.ActualBorderBRRadius, r.Bottom - b.ActualBorderBottomWidth / 2, b.ActualBorderBRRadius, RGraphicsPath.Corner.BottomRight); } break; case Border.Left: - if (b.ActualCornerNw > 0 || b.ActualCornerSw > 0) + if (b.ActualBorderTLRadius > 0 || b.ActualBorderBLRadius > 0) { path = g.GetGraphicsPath(); bool noTop = b.BorderTopStyle == CssConstants.None || b.BorderTopStyle == CssConstants.Hidden; bool noBottom = b.BorderBottomStyle == CssConstants.None || b.BorderBottomStyle == CssConstants.Hidden; - path.Start(r.Left + b.ActualBorderLeftWidth / 2 + (noBottom ? b.ActualCornerSw : 0), r.Bottom - b.ActualBorderBottomWidth / 2 - (noBottom ? 0 : b.ActualCornerSw)); + path.Start(r.Left + b.ActualBorderLeftWidth / 2 + (noBottom ? b.ActualBorderBLRadius : 0), r.Bottom - b.ActualBorderBottomWidth / 2 - (noBottom ? 0 : b.ActualBorderBLRadius)); - if (b.ActualCornerSw > 0 && noBottom) - path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualCornerSw, b.ActualCornerSw, RGraphicsPath.Corner.BottomLeft); + if (b.ActualBorderBLRadius > 0 && noBottom) + path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2, r.Bottom - b.ActualBorderBottomWidth / 2 - b.ActualBorderBLRadius, b.ActualBorderBLRadius, RGraphicsPath.Corner.BottomLeft); - path.LineTo(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualCornerNw); + path.LineTo(r.Left + b.ActualBorderLeftWidth / 2, r.Top + b.ActualBorderTopWidth / 2 + b.ActualBorderTLRadius); - if (b.ActualCornerNw > 0 && noTop) - path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2 + b.ActualCornerNw, r.Top + b.ActualBorderTopWidth / 2, b.ActualCornerNw, RGraphicsPath.Corner.TopLeft); + if (b.ActualBorderTLRadius > 0 && noTop) + path.ArcTo(r.Left + b.ActualBorderLeftWidth / 2 + b.ActualBorderTLRadius, r.Top + b.ActualBorderTopWidth / 2, b.ActualBorderTLRadius, RGraphicsPath.Corner.TopLeft); } break; } diff --git a/Source/HtmlRenderer/Core/Utils/CssUtils.cs b/Source/HtmlRenderer/Core/Utils/CssUtils.cs index 69f949390..18264f6f4 100644 --- a/Source/HtmlRenderer/Core/Utils/CssUtils.cs +++ b/Source/HtmlRenderer/Core/Utils/CssUtils.cs @@ -96,16 +96,33 @@ public static string GetPropertyValue(CssBox cssBox, string propName) return cssBox.BorderSpacing; case "border-collapse": return cssBox.BorderCollapse; + case "border-radius": + return cssBox.BorderRadius; + case "border-top-left-radius": + return cssBox.BorderTLRadius; + case "border-top-right-radius": + return cssBox.BorderTRRadius; + case "border-bottom-right-radius": + return cssBox.BorderBRRadius; + case "border-bottom-left-radius": + return cssBox.BorderBLRadius; + case "corner-radius": - return cssBox.CornerRadius; + // leave for back compatibility only. Right property for rounded borders: border-radius + return cssBox.BorderRadius; + // leave for back compatibility only. Right property for rounded corner: border-top-left-radius case "corner-nw-radius": - return cssBox.CornerNwRadius; + return cssBox.BorderTLRadius; + // leave for back compatibility only. Right property for rounded borders: border-top-right-radius case "corner-ne-radius": - return cssBox.CornerNeRadius; + return cssBox.BorderTRRadius; + // leave for back compatibility only. Right property for rounded borders: border-bottom-right-radius case "corner-se-radius": - return cssBox.CornerSeRadius; + return cssBox.BorderBRRadius; + // leave for back compatibility only. Right property for rounded borders: border-bottom-left-radius case "corner-sw-radius": - return cssBox.CornerSwRadius; + return cssBox.BorderBLRadius; + case "margin-bottom": return cssBox.MarginBottom; case "margin-left": @@ -255,21 +272,43 @@ public static void SetPropertyValue(CssBox cssBox, string propName, string value case "border-collapse": cssBox.BorderCollapse = value; break; + case "border-radius": + cssBox.BorderRadius = value; + break; + case "border-top-left-radius": + cssBox.BorderTLRadius = value; + break; + case "border-top-right-radius": + cssBox.BorderTRRadius = value; + break; + case "border-bottom-right-radius": + cssBox.BorderBRRadius = value; + break; + case "border-bottom-left-radius": + cssBox.BorderBLRadius = value; + break; + + // leave for back compatibility only. Right property for rounded borders: border-radius case "corner-radius": - cssBox.CornerRadius = value; + cssBox.BorderRadius = value; break; + // leave for back compatibility only. Right property for rounded corner: border-top-left-radius case "corner-nw-radius": - cssBox.CornerNwRadius = value; + cssBox.BorderTLRadius = value; break; + // leave for back compatibility only. Right property for rounded borders: border-top-right-radius case "corner-ne-radius": - cssBox.CornerNeRadius = value; + cssBox.BorderTRRadius = value; break; + // leave for back compatibility only. Right property for rounded borders: border-bottom-right-radius case "corner-se-radius": - cssBox.CornerSeRadius = value; + cssBox.BorderBRRadius = value; break; + // leave for back compatibility only. Right property for rounded borders: border-bottom-left-radius case "corner-sw-radius": - cssBox.CornerSwRadius = value; + cssBox.BorderBLRadius = value; break; + case "margin-bottom": cssBox.MarginBottom = value; break; diff --git a/Source/HtmlRenderer/Core/Utils/RenderUtils.cs b/Source/HtmlRenderer/Core/Utils/RenderUtils.cs index 2726b5fb2..382ce32a7 100644 --- a/Source/HtmlRenderer/Core/Utils/RenderUtils.cs +++ b/Source/HtmlRenderer/Core/Utils/RenderUtils.cs @@ -96,43 +96,43 @@ public static void DrawImageErrorIcon(RGraphics g, HtmlContainerInt htmlContaine /// /// Creates a rounded rectangle using the specified corner radius
- /// NW-----NE + /// TL------TR /// | | /// | | - /// SW-----SE + /// BL------BR ///
/// the device to draw into /// Rectangle to round - /// Radius of the north east corner - /// Radius of the north west corner - /// Radius of the south east corner - /// Radius of the south west corner + /// Radius of the top left corner + /// Radius of the top right corner + /// Radius of the bottom right corner + /// Radius of the bottom left corner /// GraphicsPath with the lines of the rounded rectangle ready to be painted - public static RGraphicsPath GetRoundRect(RGraphics g, RRect rect, double nwRadius, double neRadius, double seRadius, double swRadius) + public static RGraphicsPath GetRoundRect(RGraphics g, RRect rect, double tlRadius, double trRadius, double brRadius, double blRadius) { var path = g.GetGraphicsPath(); - path.Start(rect.Left + nwRadius, rect.Top); + path.Start(rect.Left + tlRadius, rect.Top); - path.LineTo(rect.Right - neRadius, rect.Y); + path.LineTo(rect.Right - trRadius, rect.Y); - if (neRadius > 0f) - path.ArcTo(rect.Right, rect.Top + neRadius, neRadius, RGraphicsPath.Corner.TopRight); + if (trRadius > 0f) + path.ArcTo(rect.Right, rect.Top + trRadius, trRadius, RGraphicsPath.Corner.TopRight); - path.LineTo(rect.Right, rect.Bottom - seRadius); + path.LineTo(rect.Right, rect.Bottom - brRadius); - if (seRadius > 0f) - path.ArcTo(rect.Right - seRadius, rect.Bottom, seRadius, RGraphicsPath.Corner.BottomRight); + if (brRadius > 0f) + path.ArcTo(rect.Right - brRadius, rect.Bottom, brRadius, RGraphicsPath.Corner.BottomRight); - path.LineTo(rect.Left + swRadius, rect.Bottom); + path.LineTo(rect.Left + blRadius, rect.Bottom); - if (swRadius > 0f) - path.ArcTo(rect.Left, rect.Bottom - swRadius, swRadius, RGraphicsPath.Corner.BottomLeft); + if (blRadius > 0f) + path.ArcTo(rect.Left, rect.Bottom - blRadius, blRadius, RGraphicsPath.Corner.BottomLeft); - path.LineTo(rect.Left, rect.Top + nwRadius); + path.LineTo(rect.Left, rect.Top + tlRadius); - if (nwRadius > 0f) - path.ArcTo(rect.Left + nwRadius, rect.Top, nwRadius, RGraphicsPath.Corner.TopLeft); + if (tlRadius > 0f) + path.ArcTo(rect.Left + tlRadius, rect.Top, tlRadius, RGraphicsPath.Corner.TopLeft); return path; } From bf3165625076d18834cb67f5070af0b532866c82 Mon Sep 17 00:00:00 2001 From: Andrey Ushakov Date: Wed, 11 May 2016 13:29:27 +0300 Subject: [PATCH 4/4] rollback wrong change --- Source/HtmlRenderer/Core/Dom/CssLayoutEngineTable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/HtmlRenderer/Core/Dom/CssLayoutEngineTable.cs b/Source/HtmlRenderer/Core/Dom/CssLayoutEngineTable.cs index 285ccba1b..0b57b5d27 100644 --- a/Source/HtmlRenderer/Core/Dom/CssLayoutEngineTable.cs +++ b/Source/HtmlRenderer/Core/Dom/CssLayoutEngineTable.cs @@ -630,7 +630,7 @@ private void LayoutCells(RGraphics g) LayoutRowsGroup(g, _headerBox, startx, ref dummyY, maxRight, ref dummyBottom); LayoutRowsGroup(g, _footerBox, startx, ref dummyY, maxRight, ref dummyBottom); - for (int i = 0; i < _bodyrows.Count; i++) + for (int i = 0; i < _allRows.Count; i++) { var row = _allRows[i]; double curx = startx;