-
Notifications
You must be signed in to change notification settings - Fork 545
Expand file tree
/
Copy pathCssBoxProperties.cs
More file actions
1567 lines (1406 loc) · 48.2 KB
/
CssBoxProperties.cs
File metadata and controls
1567 lines (1406 loc) · 48.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// "Therefore those skilled at the unorthodox
// are infinite as heaven and earth,
// inexhaustible as the great rivers.
// When they come to an end,
// they begin again,
// like the days and months;
// they die and are reborn,
// like the four seasons."
//
// - Sun Tsu,
// "The Art of War"
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using TheArtOfDev.HtmlRenderer.Adapters;
using TheArtOfDev.HtmlRenderer.Adapters.Entities;
using TheArtOfDev.HtmlRenderer.Core.Parse;
using TheArtOfDev.HtmlRenderer.Core.Utils;
namespace TheArtOfDev.HtmlRenderer.Core.Dom
{
/// <summary>
/// Base class for css box to handle the css properties.<br/>
/// Has field and property for every css property that can be set, the properties add additional parsing like
/// setting the correct border depending what border value was set (single, two , all four).<br/>
/// Has additional fields to control the location and size of the box and 'actual' css values for some properties
/// that require additional calculations and parsing.<br/>
/// </summary>
internal abstract class CssBoxProperties
{
#region CSS Fields
private string _backgroundColor = "transparent";
private string _backgroundGradient = "none";
private string _backgroundGradientAngle = "90";
private string _backgroundImage = "none";
private string _backgroundPosition = "0% 0%";
private string _backgroundRepeat = "repeat";
private string _borderTopWidth = "medium";
private string _borderRightWidth = "medium";
private string _borderBottomWidth = "medium";
private string _borderLeftWidth = "medium";
private string _borderTopColor = "black";
private string _borderRightColor = "black";
private string _borderBottomColor = "black";
private string _borderLeftColor = "black";
private string _borderTopStyle = "none";
private string _borderRightStyle = "none";
private string _borderBottomStyle = "none";
private string _borderLeftStyle = "none";
private string _borderSpacing = "0";
private string _borderCollapse = "separate";
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 _emptyCells = "show";
private string _direction = "ltr";
private string _display = "inline";
private string _fontFamily;
private string _fontSize = "medium";
private string _fontStyle = "normal";
private string _fontVariant = "normal";
private string _fontWeight = "normal";
private string _float = "none";
private string _height = "auto";
private string _marginBottom = "0";
private string _marginLeft = "0";
private string _marginRight = "0";
private string _marginTop = "0";
private string _left = "auto";
private string _lineHeight = "normal";
private string _listStyleType = "disc";
private string _listStyleImage = string.Empty;
private string _listStylePosition = "outside";
private string _listStyle = string.Empty;
private string _overflow = "visible";
private string _paddingLeft = "0";
private string _paddingBottom = "0";
private string _paddingRight = "0";
private string _paddingTop = "0";
private string _pageBreakInside = CssConstants.Auto;
private string _right;
private string _textAlign = string.Empty;
private string _textDecoration = string.Empty;
private string _textIndent = "0";
private string _top = "auto";
private string _position = "static";
private string _verticalAlign = "baseline";
private string _width = "auto";
private string _maxWidth = "none";
private string _wordSpacing = "normal";
private string _wordBreak = "normal";
private string _whiteSpace = "normal";
private string _visibility = "visible";
#endregion
#region Fields
/// <summary>
/// Gets or sets the location of the box
/// </summary>
private RPoint _location;
/// <summary>
/// Gets or sets the size of the box
/// </summary>
private RSize _size;
private double _actualCornerNw = double.NaN;
private double _actualCornerNe = double.NaN;
private double _actualCornerSw = double.NaN;
private double _actualCornerSe = double.NaN;
private RColor _actualColor = RColor.Empty;
private double _actualBackgroundGradientAngle = double.NaN;
private double _actualHeight = double.NaN;
private double _actualWidth = double.NaN;
private double _actualPaddingTop = double.NaN;
private double _actualPaddingBottom = double.NaN;
private double _actualPaddingRight = double.NaN;
private double _actualPaddingLeft = double.NaN;
private double _actualMarginTop = double.NaN;
private double _collapsedMarginTop = double.NaN;
private double _actualMarginBottom = double.NaN;
private double _actualMarginRight = double.NaN;
private double _actualMarginLeft = double.NaN;
private double _actualBorderTopWidth = double.NaN;
private double _actualBorderLeftWidth = double.NaN;
private double _actualBorderBottomWidth = double.NaN;
private double _actualBorderRightWidth = double.NaN;
/// <summary>
/// the width of whitespace between words
/// </summary>
private double _actualLineHeight = double.NaN;
private double _actualWordSpacing = double.NaN;
private double _actualTextIndent = double.NaN;
private double _actualBorderSpacingHorizontal = double.NaN;
private double _actualBorderSpacingVertical = double.NaN;
private RColor _actualBackgroundGradient = RColor.Empty;
private RColor _actualBorderTopColor = RColor.Empty;
private RColor _actualBorderLeftColor = RColor.Empty;
private RColor _actualBorderBottomColor = RColor.Empty;
private RColor _actualBorderRightColor = RColor.Empty;
private RColor _actualBackgroundColor = RColor.Empty;
private RFont _actualFont;
#endregion
#region CSS Properties
public string BorderBottomWidth
{
get { return _borderBottomWidth; }
set
{
_borderBottomWidth = value;
_actualBorderBottomWidth = Single.NaN;
}
}
public string BorderLeftWidth
{
get { return _borderLeftWidth; }
set
{
_borderLeftWidth = value;
_actualBorderLeftWidth = Single.NaN;
}
}
public string BorderRightWidth
{
get { return _borderRightWidth; }
set
{
_borderRightWidth = value;
_actualBorderRightWidth = Single.NaN;
}
}
public string BorderTopWidth
{
get { return _borderTopWidth; }
set
{
_borderTopWidth = value;
_actualBorderTopWidth = Single.NaN;
}
}
public string BorderBottomStyle
{
get { return _borderBottomStyle; }
set { _borderBottomStyle = value; }
}
public string BorderLeftStyle
{
get { return _borderLeftStyle; }
set { _borderLeftStyle = value; }
}
public string BorderRightStyle
{
get { return _borderRightStyle; }
set { _borderRightStyle = value; }
}
public string BorderTopStyle
{
get { return _borderTopStyle; }
set { _borderTopStyle = value; }
}
public string BorderBottomColor
{
get { return _borderBottomColor; }
set
{
_borderBottomColor = value;
_actualBorderBottomColor = RColor.Empty;
}
}
public string BorderLeftColor
{
get { return _borderLeftColor; }
set
{
_borderLeftColor = value;
_actualBorderLeftColor = RColor.Empty;
}
}
public string BorderRightColor
{
get { return _borderRightColor; }
set
{
_borderRightColor = value;
_actualBorderRightColor = RColor.Empty;
}
}
public string BorderTopColor
{
get { return _borderTopColor; }
set
{
_borderTopColor = value;
_actualBorderTopColor = RColor.Empty;
}
}
public string BorderSpacing
{
get { return _borderSpacing; }
set { _borderSpacing = value; }
}
public string BorderCollapse
{
get { return _borderCollapse; }
set { _borderCollapse = value; }
}
public string CornerRadius
{
get { return _cornerRadius; }
set
{
MatchCollection r = RegexParserUtils.Match(RegexParserUtils.CssLength, value);
switch (r.Count)
{
case 1:
CornerNeRadius = r[0].Value;
CornerNwRadius = r[0].Value;
CornerSeRadius = r[0].Value;
CornerSwRadius = r[0].Value;
break;
case 2:
CornerNeRadius = r[0].Value;
CornerNwRadius = r[0].Value;
CornerSeRadius = r[1].Value;
CornerSwRadius = r[1].Value;
break;
case 3:
CornerNeRadius = r[0].Value;
CornerNwRadius = r[1].Value;
CornerSeRadius = r[2].Value;
break;
case 4:
CornerNeRadius = r[0].Value;
CornerNwRadius = r[1].Value;
CornerSeRadius = r[2].Value;
CornerSwRadius = r[3].Value;
break;
}
_cornerRadius = value;
}
}
public string CornerNwRadius
{
get { return _cornerNwRadius; }
set { _cornerNwRadius = value; }
}
public string CornerNeRadius
{
get { return _cornerNeRadius; }
set { _cornerNeRadius = value; }
}
public string CornerSeRadius
{
get { return _cornerSeRadius; }
set { _cornerSeRadius = value; }
}
public string CornerSwRadius
{
get { return _cornerSwRadius; }
set { _cornerSwRadius = value; }
}
public string MarginBottom
{
get { return _marginBottom; }
set { _marginBottom = value; }
}
public string MarginLeft
{
get { return _marginLeft; }
set { _marginLeft = value; }
}
public string MarginRight
{
get { return _marginRight; }
set { _marginRight = value; }
}
public string MarginTop
{
get { return _marginTop; }
set { _marginTop = value; }
}
public string PaddingBottom
{
get { return _paddingBottom; }
set
{
_paddingBottom = value;
_actualPaddingBottom = double.NaN;
}
}
public string PaddingLeft
{
get { return _paddingLeft; }
set
{
_paddingLeft = value;
_actualPaddingLeft = double.NaN;
}
}
public string PaddingRight
{
get { return _paddingRight; }
set
{
_paddingRight = value;
_actualPaddingRight = double.NaN;
}
}
public string PaddingTop
{
get { return _paddingTop; }
set
{
_paddingTop = value;
_actualPaddingTop = double.NaN;
}
}
public string PageBreakInside
{
get { return _pageBreakInside; }
set
{
_pageBreakInside = value;
}
}
public string Left
{
get { return _left; }
set
{
_left = value;
if (Position == CssConstants.Fixed)
{
_location = GetActualLocation(Left, Top);
}
}
}
public string Top
{
get { return _top; }
set {
_top = value;
if (Position == CssConstants.Fixed)
{
_location = GetActualLocation(Left, Top);
}
}
}
public string Width
{
get { return _width; }
set { _width = value; }
}
public string MaxWidth
{
get { return _maxWidth; }
set { _maxWidth = value; }
}
public string Height
{
get { return _height; }
set { _height = value; }
}
public string BackgroundColor
{
get { return _backgroundColor; }
set { _backgroundColor = value; }
}
public string BackgroundImage
{
get { return _backgroundImage; }
set { _backgroundImage = value; }
}
public string BackgroundPosition
{
get { return _backgroundPosition; }
set { _backgroundPosition = value; }
}
public string BackgroundRepeat
{
get { return _backgroundRepeat; }
set { _backgroundRepeat = value; }
}
public string BackgroundGradient
{
get { return _backgroundGradient; }
set { _backgroundGradient = value; }
}
public string BackgroundGradientAngle
{
get { return _backgroundGradientAngle; }
set { _backgroundGradientAngle = value; }
}
public string Color
{
get { return _color; }
set
{
_color = value;
_actualColor = RColor.Empty;
}
}
public string Content
{
get { return _content; }
set { _content = value; }
}
public string Display
{
get { return _display; }
set { _display = value; }
}
public string Direction
{
get { return _direction; }
set { _direction = value; }
}
public string EmptyCells
{
get { return _emptyCells; }
set { _emptyCells = value; }
}
public string Float
{
get { return _float; }
set { _float = value; }
}
public string Position
{
get { return _position; }
set { _position = value; }
}
public string LineHeight
{
get { return _lineHeight; }
set { _lineHeight = string.Format(NumberFormatInfo.InvariantInfo, "{0}px", CssValueParser.ParseLength(value, Size.Height, this, CssConstants.Em)); }
}
public string VerticalAlign
{
get { return _verticalAlign; }
set { _verticalAlign = value; }
}
public string TextIndent
{
get { return _textIndent; }
set { _textIndent = NoEms(value); }
}
public string TextAlign
{
get { return _textAlign; }
set { _textAlign = value; }
}
public string TextDecoration
{
get { return _textDecoration; }
set { _textDecoration = value; }
}
public string WhiteSpace
{
get { return _whiteSpace; }
set { _whiteSpace = value; }
}
public string Visibility
{
get { return _visibility; }
set { _visibility = value; }
}
public string WordSpacing
{
get { return _wordSpacing; }
set { _wordSpacing = NoEms(value); }
}
public string WordBreak
{
get { return _wordBreak; }
set { _wordBreak = value; }
}
public string FontFamily
{
get { return _fontFamily; }
set { _fontFamily = value; }
}
public string FontSize
{
get { return _fontSize; }
set
{
string length = RegexParserUtils.Search(RegexParserUtils.CssLength, value);
if (length != null)
{
string computedValue;
CssLength len = new CssLength(length);
if (len.HasError)
{
computedValue = "medium";
}
else if (len.Unit == CssUnit.Ems && GetParent() != null)
{
computedValue = len.ConvertEmToPoints(GetParent().ActualFont.Size).ToString();
}
else
{
computedValue = len.ToString();
}
_fontSize = computedValue;
}
else
{
_fontSize = value;
}
}
}
public string FontStyle
{
get { return _fontStyle; }
set { _fontStyle = value; }
}
public string FontVariant
{
get { return _fontVariant; }
set { _fontVariant = value; }
}
public string FontWeight
{
get { return _fontWeight; }
set { _fontWeight = value; }
}
public string ListStyle
{
get { return _listStyle; }
set { _listStyle = value; }
}
public string Overflow
{
get { return _overflow; }
set { _overflow = value; }
}
public string ListStylePosition
{
get { return _listStylePosition; }
set { _listStylePosition = value; }
}
public string ListStyleImage
{
get { return _listStyleImage; }
set { _listStyleImage = value; }
}
public string ListStyleType
{
get { return _listStyleType; }
set { _listStyleType = value; }
}
#endregion CSS Propertier
/// <summary>
/// Gets or sets the location of the box
/// </summary>
public RPoint Location
{
get {
if (_location.IsEmpty && Position == CssConstants.Fixed)
{
var left = Left;
var top = Top;
_location = GetActualLocation(Left, Top);
}
return _location;
}
set {
_location = value;
}
}
/// <summary>
/// Gets or sets the size of the box
/// </summary>
public RSize Size
{
get { return _size; }
set { _size = value; }
}
/// <summary>
/// Gets the bounds of the box
/// </summary>
public RRect Bounds
{
get { return new RRect(Location, Size); }
}
/// <summary>
/// Gets the width available on the box, counting padding and margin.
/// </summary>
public double AvailableWidth
{
get { return Size.Width - ActualBorderLeftWidth - ActualPaddingLeft - ActualPaddingRight - ActualBorderRightWidth; }
}
/// <summary>
/// Gets the right of the box. When setting, it will affect only the width of the box.
/// </summary>
public double ActualRight
{
get { return Location.X + Size.Width; }
set { Size = new RSize(value - Location.X, Size.Height); }
}
/// <summary>
/// Gets or sets the bottom of the box.
/// (When setting, alters only the Size.Height of the box)
/// </summary>
public double ActualBottom
{
get { return Location.Y + Size.Height; }
set { Size = new RSize(Size.Width, value - Location.Y); }
}
/// <summary>
/// Gets the left of the client rectangle (Where content starts rendering)
/// </summary>
public double ClientLeft
{
get { return Location.X + ActualBorderLeftWidth + ActualPaddingLeft; }
}
/// <summary>
/// Gets the top of the client rectangle (Where content starts rendering)
/// </summary>
public double ClientTop
{
get { return Location.Y + ActualBorderTopWidth + ActualPaddingTop; }
}
/// <summary>
/// Gets the right of the client rectangle
/// </summary>
public double ClientRight
{
get { return ActualRight - ActualPaddingRight - ActualBorderRightWidth; }
}
/// <summary>
/// Gets the bottom of the client rectangle
/// </summary>
public double ClientBottom
{
get { return ActualBottom - ActualPaddingBottom - ActualBorderBottomWidth; }
}
/// <summary>
/// Gets the client rectangle
/// </summary>
public RRect ClientRectangle
{
get { return RRect.FromLTRB(ClientLeft, ClientTop, ClientRight, ClientBottom); }
}
/// <summary>
/// Gets the actual height
/// </summary>
public double ActualHeight
{
get
{
if (double.IsNaN(_actualHeight))
{
_actualHeight = CssValueParser.ParseLength(Height, Size.Height, this);
}
return _actualHeight;
}
}
/// <summary>
/// Gets the actual height
/// </summary>
public double ActualWidth
{
get
{
if (double.IsNaN(_actualWidth))
{
_actualWidth = CssValueParser.ParseLength(Width, Size.Width, this);
}
return _actualWidth;
}
}
/// <summary>
/// Gets the actual top's padding
/// </summary>
public double ActualPaddingTop
{
get
{
if (double.IsNaN(_actualPaddingTop))
{
_actualPaddingTop = CssValueParser.ParseLength(PaddingTop, Size.Width, this);
}
return _actualPaddingTop;
}
}
/// <summary>
/// Gets the actual padding on the left
/// </summary>
public double ActualPaddingLeft
{
get
{
if (double.IsNaN(_actualPaddingLeft))
{
_actualPaddingLeft = CssValueParser.ParseLength(PaddingLeft, Size.Width, this);
}
return _actualPaddingLeft;
}
}
/// <summary>
/// Gets the actual Padding of the bottom
/// </summary>
public double ActualPaddingBottom
{
get
{
if (double.IsNaN(_actualPaddingBottom))
{
_actualPaddingBottom = CssValueParser.ParseLength(PaddingBottom, Size.Width, this);
}
return _actualPaddingBottom;
}
}
/// <summary>
/// Gets the actual padding on the right
/// </summary>
public double ActualPaddingRight
{
get
{
if (double.IsNaN(_actualPaddingRight))
{
_actualPaddingRight = CssValueParser.ParseLength(PaddingRight, Size.Width, this);
}
return _actualPaddingRight;
}
}
/// <summary>
/// Gets the actual top's Margin
/// </summary>
public double ActualMarginTop
{
get
{
if (double.IsNaN(_actualMarginTop))
{
if (MarginTop == CssConstants.Auto)
MarginTop = "0";
var actualMarginTop = CssValueParser.ParseLength(MarginTop, Size.Width, this);
if (MarginLeft.EndsWith("%"))
return actualMarginTop;
_actualMarginTop = actualMarginTop;
}
return _actualMarginTop;
}
}
/// <summary>
/// The margin top value if was effected by margin collapse.
/// </summary>
public double CollapsedMarginTop
{
get { return double.IsNaN(_collapsedMarginTop) ? 0 : _collapsedMarginTop; }
set { _collapsedMarginTop = value; }
}
/// <summary>
/// Gets the actual Margin on the left
/// </summary>
public double ActualMarginLeft
{
get
{
if (double.IsNaN(_actualMarginLeft))
{
if (MarginLeft == CssConstants.Auto)
MarginLeft = "0";
var actualMarginLeft = CssValueParser.ParseLength(MarginLeft, Size.Width, this);
if (MarginLeft.EndsWith("%"))
return actualMarginLeft;
_actualMarginLeft = actualMarginLeft;
}
return _actualMarginLeft;
}
}
/// <summary>
/// Gets the actual Margin of the bottom
/// </summary>
public double ActualMarginBottom
{
get
{
if (double.IsNaN(_actualMarginBottom))
{
if (MarginBottom == CssConstants.Auto)
MarginBottom = "0";
var actualMarginBottom = CssValueParser.ParseLength(MarginBottom, Size.Width, this);
if (MarginLeft.EndsWith("%"))
return actualMarginBottom;
_actualMarginBottom = actualMarginBottom;
}
return _actualMarginBottom;
}
}
/// <summary>
/// Gets the actual Margin on the right
/// </summary>
public double ActualMarginRight
{
get
{
if (double.IsNaN(_actualMarginRight))
{
if (MarginRight == CssConstants.Auto)
MarginRight = "0";
var actualMarginRight = CssValueParser.ParseLength(MarginRight, Size.Width, this);
if (MarginLeft.EndsWith("%"))
return actualMarginRight;
_actualMarginRight = actualMarginRight;
}
return _actualMarginRight;
}
}
/// <summary>
/// Gets the actual top border width
/// </summary>
public double ActualBorderTopWidth
{
get
{
if (double.IsNaN(_actualBorderTopWidth))
{
_actualBorderTopWidth = CssValueParser.GetActualBorderWidth(BorderTopWidth, this);
if (string.IsNullOrEmpty(BorderTopStyle) || BorderTopStyle == CssConstants.None)
{
_actualBorderTopWidth = 0f;
}
}
return _actualBorderTopWidth;
}
}
/// <summary>
/// Gets the actual Left border width
/// </summary>
public double ActualBorderLeftWidth
{
get
{
if (double.IsNaN(_actualBorderLeftWidth))
{
_actualBorderLeftWidth = CssValueParser.GetActualBorderWidth(BorderLeftWidth, this);
if (string.IsNullOrEmpty(BorderLeftStyle) || BorderLeftStyle == CssConstants.None)
{
_actualBorderLeftWidth = 0f;
}
}