WIP CSSOM value model
This commit is contained in:
Родитель
9cc365f6a2
Коммит
847d59a3bd
|
@ -3,11 +3,13 @@
|
|||
Released on Thursday, May 5 2019.
|
||||
|
||||
- Reference latest AngleSharp
|
||||
- Fixed empty value when removing properties (#14)
|
||||
- Returns `null` in `GetStyle` if CSS not configured (#15)
|
||||
- Added `pointer-events` and fixed border recombination (#16)
|
||||
- Fixed exception when not providing an `IRenderDevice` (#20)
|
||||
- Fixed missing `CssStylingService.Default` in cascade (#21)
|
||||
- Added extension helper `SetStyle` to modify all styles of many elements (#22)
|
||||
- Opened CSSOM, e.g., declared `ICssFunctionValue` `public` (#24)
|
||||
- Introduced special converter for the `src` declaration (#25)
|
||||
- Fixed bug regarding CSS grid serialization (#27)
|
||||
|
||||
|
|
|
@ -5,143 +5,146 @@ namespace AngleSharp.Css.Constants
|
|||
using AngleSharp.Dom;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// A collection of initial values for the respective CSS declarations.
|
||||
/// </summary>
|
||||
static class InitialValues
|
||||
{
|
||||
public static readonly ICssValue ColorDeclaration = Color.Black;
|
||||
public static readonly ICssValue BackgroundColorDeclaration = Color.Transparent;
|
||||
public static readonly ICssValue BackgroundImageDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue BackgroundRepeatDeclaration = new ImageRepeats(new Identifier(CssKeywords.Repeat), new Identifier(CssKeywords.Repeat));
|
||||
public static readonly ICssValue BackgroundPositionDeclaration = new CssTupleValue(new ICssValue[] { new Length(0, Length.Unit.Percent), new Length(0, Length.Unit.Percent) });
|
||||
public static readonly ICssValue BackgroundSizeDeclaration = new BackgroundSize(new Constant<Length>(CssKeywords.Auto, Length.Auto), new Constant<Length>(CssKeywords.Auto, Length.Auto));
|
||||
public static readonly ICssValue BackgroundOriginDeclaration = new Constant<BoxModel>(CssKeywords.BorderBox, BoxModel.PaddingBox);
|
||||
public static readonly ICssValue BackgroundClipDeclaration = new Constant<BoxModel>(CssKeywords.BorderBox, BoxModel.BorderBox);
|
||||
public static readonly ICssValue BackgroundAttachmentDeclaration = new Constant<BackgroundAttachment>(CssKeywords.Scroll, BackgroundAttachment.Scroll);
|
||||
public static readonly ICssValue FontStyleDeclaration = new Constant<FontStyle>(CssKeywords.Normal, FontStyle.Normal);
|
||||
public static readonly ICssValue FontVariantDeclaration = new Constant<FontVariant>(CssKeywords.Normal, FontVariant.Normal);
|
||||
public static readonly ICssValue FontWeightDeclaration = new Constant<FontWeight>(CssKeywords.Normal, FontWeight.Normal);
|
||||
public static readonly ICssValue FontStretchDeclaration = new Constant<FontStretch>(CssKeywords.Normal, FontStretch.Normal);
|
||||
public static readonly ICssValue FontSizeDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue FontFamilyDeclaration = new StringValue("Times New Roman");
|
||||
public static readonly ICssValue LineHeightDeclaration = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue BorderTopWidthDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderRightWidthDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderBottomWidthDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderLeftWidthDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderTopStyleDeclaration = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderRightStyleDeclaration = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderBottomStyleDeclaration = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderLeftStyleDeclaration = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderTopColorDeclaration = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue BorderRightColorDeclaration = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue BorderBottomColorDeclaration = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue BorderLeftColorDeclaration = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue ColumnWidthDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ColumnCountDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ColumnRuleWidthDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue ColumnRuleStyleDeclaration = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue ColumnRuleColorDeclaration = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue AnimationNameDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue AnimationDurationDeclaration = Time.Zero;
|
||||
public static readonly ICssValue AnimationTimingFunctionDeclaration = CubicBezierTimingFunction.Ease;
|
||||
public static readonly ICssValue AnimationDelayDeclaration = Time.Zero;
|
||||
public static readonly ICssValue AnimationIterationCountDeclaration = new Length(1, Length.Unit.None);
|
||||
public static readonly ICssValue AnimationDirectionDeclaration = new Constant<AnimationDirection>(CssKeywords.Normal, AnimationDirection.Normal);
|
||||
public static readonly ICssValue AnimationFillModeDeclaration = new Constant<AnimationFillStyle>(CssKeywords.None, AnimationFillStyle.None);
|
||||
public static readonly ICssValue AnimationPlayStateDeclaration = new Constant<PlayState>(CssKeywords.Running, PlayState.Running);
|
||||
public static readonly ICssValue TransitionDelayDeclaration = Time.Zero;
|
||||
public static readonly ICssValue TransitionDurationDeclaration = Time.Zero;
|
||||
public static readonly ICssValue TransitionPropertyDeclaration = new Identifier(CssKeywords.All);
|
||||
public static readonly ICssValue TransitionTimingFunctionDeclaration = CubicBezierTimingFunction.Ease;
|
||||
public static readonly ICssValue DirectionDeclaration = new Constant<DirectionMode>(CssKeywords.Ltr, DirectionMode.Ltr);
|
||||
public static readonly ICssValue EmptyCellsDeclaration = new Constant<Boolean>(CssKeywords.Show, true);
|
||||
public static readonly ICssValue FlexGrowDeclaration = new Length(0, Length.Unit.None);
|
||||
public static readonly ICssValue FlexShrinkDeclaration = new Length(1, Length.Unit.None);
|
||||
public static readonly ICssValue FlexBasisDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue FloatDeclaration = new Constant<Floating>(CssKeywords.None, Floating.None);
|
||||
public static readonly ICssValue BorderSpacingDeclaration = Length.Zero;
|
||||
public static readonly ICssValue BoxShadowDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue BoxSizingDeclaration = new Constant<BoxModel>(CssKeywords.ContentBox, BoxModel.ContentBox);
|
||||
public static readonly ICssValue BreakAfterDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue BreakBeforeDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue BreakInsideDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue PageBreakInsideDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue PageBreakBeforeDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue PageBreakAfterDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue BottomDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue TopDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue LeftDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue RightDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue MinHeightDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue MinWidthDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue MaxHeightDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue MaxWidthDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue MarginLeftDeclaration = Length.Zero;
|
||||
public static readonly ICssValue MarginBottomDeclaration = Length.Zero;
|
||||
public static readonly ICssValue MarginRightDeclaration = Length.Zero;
|
||||
public static readonly ICssValue MarginTopDeclaration = Length.Zero;
|
||||
public static readonly ICssValue PaddingLeftDeclaration = Length.Zero;
|
||||
public static readonly ICssValue PaddingBottomDeclaration = Length.Zero;
|
||||
public static readonly ICssValue PaddingRightDeclaration = Length.Zero;
|
||||
public static readonly ICssValue PaddingTopDeclaration = Length.Zero;
|
||||
public static readonly ICssValue CaptionSideDeclaration = new Constant<Boolean>(CssKeywords.Top, true);
|
||||
public static readonly ICssValue CursorDeclaration = new Constant<SystemCursor>(CssKeywords.Auto, SystemCursor.Auto);
|
||||
public static readonly ICssValue OverflowWrapDeclaration = new Constant<OverflowWrap>(CssKeywords.Normal, OverflowWrap.Normal);
|
||||
public static readonly ICssValue WordSpacingDeclaration = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue WordBreakDeclaration = new Constant<WordBreak>(CssKeywords.Normal, WordBreak.Normal);
|
||||
public static readonly ICssValue VisibilityDeclaration = new Constant<Visibility>(CssKeywords.Visible, Visibility.Visible);
|
||||
public static readonly ICssValue VerticalAlignDeclaration = new Constant<VerticalAlignment>(CssKeywords.Baseline, VerticalAlignment.Baseline);
|
||||
public static readonly ICssValue OpacityDeclaration = new Length(1.0, Length.Unit.None);
|
||||
public static readonly ICssValue OverflowDeclaration = new Constant<OverflowMode>(CssKeywords.Visible, OverflowMode.Visible);
|
||||
public static readonly ICssValue OutlineWidthDeclaration = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue OutlineStyleDeclaration = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue OutlineColorDeclaration = new Constant<Color>(CssKeywords.Invert, Color.InvertedColor);
|
||||
public static readonly ICssValue TextTransformDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue TextShadowDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue TextRenderingDeclaration = new Constant<Object>(CssKeywords.Auto, null);
|
||||
public static readonly ICssValue TextOverflowDeclaration = new Constant<OverflowMode>(CssKeywords.Auto, OverflowMode.Clip);
|
||||
public static readonly ICssValue TextOrientationDeclaration = new Constant<Object>(CssKeywords.Mixed, null);
|
||||
public static readonly ICssValue TextJustifyDeclaration = new Constant<TextJustify>(CssKeywords.Auto, TextJustify.Auto);
|
||||
public static readonly ICssValue TextIndentDeclaration = Length.Zero;
|
||||
public static readonly ICssValue TextAlignDeclaration = new Constant<HorizontalAlignment>(CssKeywords.Left, HorizontalAlignment.Left);
|
||||
public static readonly ICssValue TextAlignLastDeclaration = new Constant<TextAlignLast>(CssKeywords.Auto, TextAlignLast.Auto);
|
||||
public static readonly ICssValue TextDecorationLineDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue TextDecorationStyleDeclaration = new Constant<LineStyle>(CssKeywords.Solid, LineStyle.Solid);
|
||||
public static readonly ICssValue TextDecorationColorDeclaration = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue ListStyleTypeDeclaration = new Constant<ListStyle>(CssKeywords.Disc, ListStyle.Disc);
|
||||
public static readonly ICssValue ListStylePositionDeclaration = new Constant<ListPosition>(CssKeywords.Outside, ListPosition.Outside);
|
||||
public static readonly ICssValue ListStyleImageDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue LineBreakDeclaration = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue GridTemplateRowsDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue GridTemplateColumnsDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue GridTemplateAreasDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue GridAutoRowsDeclaration = new Constant<Object>(CssKeywords.Auto, null);
|
||||
public static readonly ICssValue GridAutoColumnsDeclaration = new Constant<Object>(CssKeywords.Auto, null);
|
||||
public static readonly ICssValue GridAutoFlowDeclaration = new Constant<Boolean>(CssKeywords.Row, false);
|
||||
public static readonly ICssValue GridColumnGapDeclaration = Length.Zero;
|
||||
public static readonly ICssValue GridRowGapDeclaration = Length.Zero;
|
||||
public static readonly ICssValue ColumnGapDeclaration = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue RowGapDeclaration = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue PerspectiveDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue PositionDeclaration = new Constant<PositionMode>(CssKeywords.Inline, PositionMode.Static);
|
||||
public static readonly ICssValue TransformDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue ClearModeDeclaration = new Constant<ClearMode>(CssKeywords.None, ClearMode.None);
|
||||
public static readonly ICssValue ClipDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ContentDeclaration = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue CounterIncrementDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue CounterResetDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue DisplayDeclaration = new Constant<DisplayMode>(CssKeywords.Inline, DisplayMode.Inline);
|
||||
public static readonly ICssValue BackfaceVisibilityDeclaration = new Constant<Visibility>(CssKeywords.Visible, Visibility.Visible);
|
||||
public static readonly ICssValue BorderImageSourceDeclaration = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue BorderImageSliceDeclaration = Length.Full;
|
||||
public static readonly ICssValue BorderImageWidthDeclaration = new Length(1, Length.Unit.None);
|
||||
public static readonly ICssValue BorderImageOutsetDeclaration = Length.Zero;
|
||||
public static readonly ICssValue BorderImageRepeatDeclaration = new Constant<BorderRepeat>(CssKeywords.Stretch, BorderRepeat.Stretch);
|
||||
public static readonly ICssValue AlignSelfDeclaration = new Constant<FlexContentMode>(CssKeywords.Auto, FlexContentMode.Auto);
|
||||
public static readonly ICssValue AlignItemsDeclaration = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue AlignContentDeclaration = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue JustifyContentDeclaration = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue JustifyItemsDeclaration = new Constant<Object>(CssKeywords.Legacy, null);
|
||||
public static readonly ICssValue JustifySelfDeclaration = new Constant<FlexContentMode>(CssKeywords.Auto, FlexContentMode.Auto);
|
||||
public static readonly ICssValue ZIndexDeclaration = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ColorDecl = Color.Black;
|
||||
public static readonly ICssValue BackgroundColorDecl = Color.Transparent;
|
||||
public static readonly ICssValue BackgroundImageDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue BackgroundRepeatDecl = new ImageRepeats(new Identifier(CssKeywords.Repeat), new Identifier(CssKeywords.Repeat));
|
||||
public static readonly ICssValue BackgroundPositionDecl = new CssTupleValue(new ICssValue[] { new Length(0, Length.Unit.Percent), new Length(0, Length.Unit.Percent) });
|
||||
public static readonly ICssValue BackgroundSizeDecl = new BackgroundSize(new Constant<Length>(CssKeywords.Auto, Length.Auto), new Constant<Length>(CssKeywords.Auto, Length.Auto));
|
||||
public static readonly ICssValue BackgroundOriginDecl = new Constant<BoxModel>(CssKeywords.BorderBox, BoxModel.PaddingBox);
|
||||
public static readonly ICssValue BackgroundClipDecl = new Constant<BoxModel>(CssKeywords.BorderBox, BoxModel.BorderBox);
|
||||
public static readonly ICssValue BackgroundAttachmentDecl = new Constant<BackgroundAttachment>(CssKeywords.Scroll, BackgroundAttachment.Scroll);
|
||||
public static readonly ICssValue FontStyleDecl = new Constant<FontStyle>(CssKeywords.Normal, FontStyle.Normal);
|
||||
public static readonly ICssValue FontVariantDecl = new Constant<FontVariant>(CssKeywords.Normal, FontVariant.Normal);
|
||||
public static readonly ICssValue FontWeightDecl = new Constant<FontWeight>(CssKeywords.Normal, FontWeight.Normal);
|
||||
public static readonly ICssValue FontStretchDecl = new Constant<FontStretch>(CssKeywords.Normal, FontStretch.Normal);
|
||||
public static readonly ICssValue FontSizeDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue FontFamilyDecl = new Label("Times New Roman");
|
||||
public static readonly ICssValue LineHeightDecl = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue BorderTopWidthDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderRightWidthDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderBottomWidthDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderLeftWidthDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue BorderTopStyleDecl = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderRightStyleDecl = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderBottomStyleDecl = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderLeftStyleDecl = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue BorderTopColorDecl = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue BorderRightColorDecl = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue BorderBottomColorDecl = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue BorderLeftColorDecl = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue ColumnWidthDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ColumnCountDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ColumnRuleWidthDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue ColumnRuleStyleDecl = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue ColumnRuleColorDecl = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue AnimationNameDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue AnimationDurationDecl = Time.Zero;
|
||||
public static readonly ICssValue AnimationTimingFunctionDecl = CubicBezierTimingFunction.Ease;
|
||||
public static readonly ICssValue AnimationDelayDecl = Time.Zero;
|
||||
public static readonly ICssValue AnimationIterationCountDecl = new Length(1, Length.Unit.None);
|
||||
public static readonly ICssValue AnimationDirectionDecl = new Constant<AnimationDirection>(CssKeywords.Normal, AnimationDirection.Normal);
|
||||
public static readonly ICssValue AnimationFillModeDecl = new Constant<AnimationFillStyle>(CssKeywords.None, AnimationFillStyle.None);
|
||||
public static readonly ICssValue AnimationPlayStateDecl = new Constant<PlayState>(CssKeywords.Running, PlayState.Running);
|
||||
public static readonly ICssValue TransitionDelayDecl = Time.Zero;
|
||||
public static readonly ICssValue TransitionDurationDecl = Time.Zero;
|
||||
public static readonly ICssValue TransitionPropertyDecl = new Identifier(CssKeywords.All);
|
||||
public static readonly ICssValue TransitionTimingFunctionDecl = CubicBezierTimingFunction.Ease;
|
||||
public static readonly ICssValue DirectionDecl = new Constant<DirectionMode>(CssKeywords.Ltr, DirectionMode.Ltr);
|
||||
public static readonly ICssValue EmptyCellsDecl = new Constant<Boolean>(CssKeywords.Show, true);
|
||||
public static readonly ICssValue FlexGrowDecl = new Length(0, Length.Unit.None);
|
||||
public static readonly ICssValue FlexShrinkDecl = new Length(1, Length.Unit.None);
|
||||
public static readonly ICssValue FlexBasisDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue FloatDecl = new Constant<Floating>(CssKeywords.None, Floating.None);
|
||||
public static readonly ICssValue BorderSpacingDecl = Length.Zero;
|
||||
public static readonly ICssValue BoxShadowDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue BoxSizingDecl = new Constant<BoxModel>(CssKeywords.ContentBox, BoxModel.ContentBox);
|
||||
public static readonly ICssValue BreakAfterDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue BreakBeforeDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue BreakInsideDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue PageBreakInsideDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue PageBreakBeforeDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue PageBreakAfterDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue BottomDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue TopDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue LeftDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue RightDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue MinHeightDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue MinWidthDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue MaxHeightDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue MaxWidthDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue MarginLeftDecl = Length.Zero;
|
||||
public static readonly ICssValue MarginBottomDecl = Length.Zero;
|
||||
public static readonly ICssValue MarginRightDecl = Length.Zero;
|
||||
public static readonly ICssValue MarginTopDecl = Length.Zero;
|
||||
public static readonly ICssValue PaddingLeftDecl = Length.Zero;
|
||||
public static readonly ICssValue PaddingBottomDecl = Length.Zero;
|
||||
public static readonly ICssValue PaddingRightDecl = Length.Zero;
|
||||
public static readonly ICssValue PaddingTopDecl = Length.Zero;
|
||||
public static readonly ICssValue CaptionSideDecl = new Constant<Boolean>(CssKeywords.Top, true);
|
||||
public static readonly ICssValue CursorDecl = new Constant<SystemCursor>(CssKeywords.Auto, SystemCursor.Auto);
|
||||
public static readonly ICssValue OverflowWrapDecl = new Constant<OverflowWrap>(CssKeywords.Normal, OverflowWrap.Normal);
|
||||
public static readonly ICssValue WordSpacingDecl = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue WordBreakDecl = new Constant<WordBreak>(CssKeywords.Normal, WordBreak.Normal);
|
||||
public static readonly ICssValue VisibilityDecl = new Constant<Visibility>(CssKeywords.Visible, Visibility.Visible);
|
||||
public static readonly ICssValue VerticalAlignDecl = new Constant<VerticalAlignment>(CssKeywords.Baseline, VerticalAlignment.Baseline);
|
||||
public static readonly ICssValue OpacityDecl = new Length(1.0, Length.Unit.None);
|
||||
public static readonly ICssValue OverflowDecl = new Constant<OverflowMode>(CssKeywords.Visible, OverflowMode.Visible);
|
||||
public static readonly ICssValue OutlineWidthDecl = new Constant<Length>(CssKeywords.Medium, Length.Medium);
|
||||
public static readonly ICssValue OutlineStyleDecl = new Constant<LineStyle>(CssKeywords.None, LineStyle.None);
|
||||
public static readonly ICssValue OutlineColorDecl = new Constant<Color>(CssKeywords.Invert, Color.InvertedColor);
|
||||
public static readonly ICssValue TextTransformDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue TextShadowDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue TextRenderingDecl = new Constant<Object>(CssKeywords.Auto, null);
|
||||
public static readonly ICssValue TextOverflowDecl = new Constant<OverflowMode>(CssKeywords.Auto, OverflowMode.Clip);
|
||||
public static readonly ICssValue TextOrientationDecl = new Constant<Object>(CssKeywords.Mixed, null);
|
||||
public static readonly ICssValue TextJustifyDecl = new Constant<TextJustify>(CssKeywords.Auto, TextJustify.Auto);
|
||||
public static readonly ICssValue TextIndentDecl = Length.Zero;
|
||||
public static readonly ICssValue TextAlignDecl = new Constant<HorizontalAlignment>(CssKeywords.Left, HorizontalAlignment.Left);
|
||||
public static readonly ICssValue TextAlignLastDecl = new Constant<TextAlignLast>(CssKeywords.Auto, TextAlignLast.Auto);
|
||||
public static readonly ICssValue TextDecorationLineDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue TextDecorationStyleDecl = new Constant<LineStyle>(CssKeywords.Solid, LineStyle.Solid);
|
||||
public static readonly ICssValue TextDecorationColorDecl = new Constant<Color>(CssKeywords.CurrentColor, Color.CurrentColor);
|
||||
public static readonly ICssValue ListStyleTypeDecl = new Constant<ListStyle>(CssKeywords.Disc, ListStyle.Disc);
|
||||
public static readonly ICssValue ListStylePositionDecl = new Constant<ListPosition>(CssKeywords.Outside, ListPosition.Outside);
|
||||
public static readonly ICssValue ListStyleImageDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue LineBreakDecl = new Constant<BreakMode>(CssKeywords.Auto, BreakMode.Auto);
|
||||
public static readonly ICssValue GridTemplateRowsDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue GridTemplateColumnsDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue GridTemplateAreasDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue GridAutoRowsDecl = new Constant<Object>(CssKeywords.Auto, null);
|
||||
public static readonly ICssValue GridAutoColumnsDecl = new Constant<Object>(CssKeywords.Auto, null);
|
||||
public static readonly ICssValue GridAutoFlowDecl = new Constant<Boolean>(CssKeywords.Row, false);
|
||||
public static readonly ICssValue GridColumnGapDecl = Length.Zero;
|
||||
public static readonly ICssValue GridRowGapDecl = Length.Zero;
|
||||
public static readonly ICssValue ColumnGapDecl = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue RowGapDecl = new Constant<Length>(CssKeywords.Normal, Length.Normal);
|
||||
public static readonly ICssValue PerspectiveDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue PositionDecl = new Constant<PositionMode>(CssKeywords.Inline, PositionMode.Static);
|
||||
public static readonly ICssValue TransformDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue ClearModeDecl = new Constant<ClearMode>(CssKeywords.None, ClearMode.None);
|
||||
public static readonly ICssValue ClipDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
public static readonly ICssValue ContentDecl = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue CounterIncrementDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue CounterResetDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue DisplayDecl = new Constant<DisplayMode>(CssKeywords.Inline, DisplayMode.Inline);
|
||||
public static readonly ICssValue BackfaceVisibilityDecl = new Constant<Visibility>(CssKeywords.Visible, Visibility.Visible);
|
||||
public static readonly ICssValue BorderImageSourceDecl = new Constant<Object>(CssKeywords.None, null);
|
||||
public static readonly ICssValue BorderImageSliceDecl = Length.Full;
|
||||
public static readonly ICssValue BorderImageWidthDecl = new Length(1, Length.Unit.None);
|
||||
public static readonly ICssValue BorderImageOutsetDecl = Length.Zero;
|
||||
public static readonly ICssValue BorderImageRepeatDecl = new Constant<BorderRepeat>(CssKeywords.Stretch, BorderRepeat.Stretch);
|
||||
public static readonly ICssValue AlignSelfDecl = new Constant<FlexContentMode>(CssKeywords.Auto, FlexContentMode.Auto);
|
||||
public static readonly ICssValue AlignItemsDecl = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue AlignContentDecl = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue JustifyContentDecl = new Constant<Object>(CssKeywords.Normal, null);
|
||||
public static readonly ICssValue JustifyItemsDecl = new Constant<Object>(CssKeywords.Legacy, null);
|
||||
public static readonly ICssValue JustifySelfDecl = new Constant<FlexContentMode>(CssKeywords.Auto, FlexContentMode.Auto);
|
||||
public static readonly ICssValue ZIndexDecl = new Constant<Length>(CssKeywords.Auto, Length.Auto);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace AngleSharp.Css.Converters
|
|||
{
|
||||
var value = source.Content;
|
||||
source.Next(value.Length);
|
||||
return new CssAnyValue(value);
|
||||
return new AnyValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,9 +151,7 @@ namespace AngleSharp.Css.Declarations
|
|||
|
||||
public ICssValue[] Split(ICssValue value)
|
||||
{
|
||||
var background = value as Background;
|
||||
|
||||
if (background != null)
|
||||
if (value is Background background)
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
|
@ -215,9 +213,7 @@ namespace AngleSharp.Css.Declarations
|
|||
|
||||
private static ICssValue CreateMultiple(Background background, Func<BackgroundLayer, ICssValue> getValue)
|
||||
{
|
||||
var layers = background.Layers as CssListValue;
|
||||
|
||||
if (layers != null)
|
||||
if (background.Layers is CssListValue layers)
|
||||
{
|
||||
var values = layers.Items.OfType<BackgroundLayer>().Select(getValue);
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ namespace AngleSharp.Css
|
|||
/// <summary>
|
||||
/// Contains the string-TimingFunction mapping.
|
||||
/// </summary>
|
||||
public static readonly Dictionary<String, ITimingFunction> TimingFunctions = new Dictionary<String, ITimingFunction>(StringComparer.OrdinalIgnoreCase)
|
||||
public static readonly Dictionary<String, ICssTimingFunctionValue> TimingFunctions = new Dictionary<String, ICssTimingFunctionValue>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ CssKeywords.Ease, new CubicBezierTimingFunction(0.25, 0.1, 0.25, 1.0) },
|
||||
{ CssKeywords.EaseIn, new CubicBezierTimingFunction(0.42, 0.0, 1.0, 1.0) },
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace AngleSharp.Css.Parser
|
|||
return null;
|
||||
}
|
||||
|
||||
public static IImageSource ParseImageSource(this StringSource source)
|
||||
public static ICssImageValue ParseImageSource(this StringSource source)
|
||||
{
|
||||
var url = source.ParseUri();
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Parser
|
|||
|
||||
static class GradientParser
|
||||
{
|
||||
private static readonly Dictionary<String, Func<StringSource, IGradient>> GradientFunctions = new Dictionary<string, Func<StringSource, IGradient>>
|
||||
private static readonly Dictionary<String, Func<StringSource, ICssGradientFunctionValue>> GradientFunctions = new Dictionary<string, Func<StringSource, ICssGradientFunctionValue>>
|
||||
{
|
||||
{ FunctionNames.LinearGradient, ParseLinearGradient },
|
||||
{ FunctionNames.RepeatingLinearGradient, ParseRepeatingLinearGradient },
|
||||
|
@ -16,7 +16,7 @@ namespace AngleSharp.Css.Parser
|
|||
{ FunctionNames.RepeatingRadialGradient, ParseRepeatingRadialGradient },
|
||||
};
|
||||
|
||||
public static IGradient ParseGradient(this StringSource source)
|
||||
public static ICssGradientFunctionValue ParseGradient(this StringSource source)
|
||||
{
|
||||
var pos = source.Index;
|
||||
var ident = source.ParseIdent();
|
||||
|
@ -25,7 +25,7 @@ namespace AngleSharp.Css.Parser
|
|||
{
|
||||
if (source.Current == Symbols.RoundBracketOpen)
|
||||
{
|
||||
var function = default(Func<StringSource, IGradient>);
|
||||
var function = default(Func<StringSource, ICssGradientFunctionValue>);
|
||||
|
||||
if (GradientFunctions.TryGetValue(ident, out function))
|
||||
{
|
||||
|
@ -39,12 +39,12 @@ namespace AngleSharp.Css.Parser
|
|||
return null;
|
||||
}
|
||||
|
||||
private static IGradient ParseLinearGradient(StringSource source)
|
||||
private static ICssGradientFunctionValue ParseLinearGradient(StringSource source)
|
||||
{
|
||||
return ParseLinearGradient(source, false);
|
||||
}
|
||||
|
||||
private static IGradient ParseRepeatingLinearGradient(StringSource source)
|
||||
private static ICssGradientFunctionValue ParseRepeatingLinearGradient(StringSource source)
|
||||
{
|
||||
return ParseLinearGradient(source, true);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ namespace AngleSharp.Css.Parser
|
|||
/// Parses a linear gradient.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/linear-gradient
|
||||
/// </summary>
|
||||
private static IGradient ParseLinearGradient(StringSource source, Boolean repeating)
|
||||
private static ICssGradientFunctionValue ParseLinearGradient(StringSource source, Boolean repeating)
|
||||
{
|
||||
var start = source.Index;
|
||||
var angle = ParseLinearAngle(source);
|
||||
|
@ -85,12 +85,12 @@ namespace AngleSharp.Css.Parser
|
|||
return null;
|
||||
}
|
||||
|
||||
private static IGradient ParseRadialGradient(StringSource source)
|
||||
private static ICssGradientFunctionValue ParseRadialGradient(StringSource source)
|
||||
{
|
||||
return ParseRadialGradient(source, false);
|
||||
}
|
||||
|
||||
private static IGradient ParseRepeatingRadialGradient(StringSource source)
|
||||
private static ICssGradientFunctionValue ParseRepeatingRadialGradient(StringSource source)
|
||||
{
|
||||
return ParseRadialGradient(source, true);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ namespace AngleSharp.Css.Parser
|
|||
/// Parses a radial gradient
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/radial-gradient
|
||||
/// </summary>
|
||||
private static IGradient ParseRadialGradient(StringSource source, Boolean repeating)
|
||||
private static ICssGradientFunctionValue ParseRadialGradient(StringSource source, Boolean repeating)
|
||||
{
|
||||
var start = source.Index;
|
||||
var options = ParseRadialOptions(source);
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace AngleSharp.Css.Parser
|
|||
hasValue = true;
|
||||
source.SkipSpacesAndComments();
|
||||
rowValues.Add(new CssTupleValue(new[] { value.Item1, value.Item3, value.Item4 }));
|
||||
areaValues.Add(new StringValue(value.Item2));
|
||||
areaValues.Add(new Label(value.Item2));
|
||||
}
|
||||
|
||||
if (hasValue)
|
||||
|
|
|
@ -130,7 +130,7 @@ namespace AngleSharp.Css.Parser
|
|||
return null;
|
||||
}
|
||||
|
||||
return new StringValue(str);
|
||||
return new Label(str);
|
||||
}
|
||||
|
||||
public static ICssValue[] ParseFontFamilies(this StringSource source)
|
||||
|
|
|
@ -7,23 +7,23 @@ namespace AngleSharp.Css.Parser
|
|||
|
||||
static class TimingFunctionParser
|
||||
{
|
||||
private static readonly Dictionary<String, Func<StringSource, ITimingFunction>> TimingFunctions = new Dictionary<String, Func<StringSource, ITimingFunction>>
|
||||
private static readonly Dictionary<String, Func<StringSource, ICssTimingFunctionValue>> TimingFunctions = new Dictionary<String, Func<StringSource, ICssTimingFunctionValue>>
|
||||
{
|
||||
{ FunctionNames.Steps, ParseSteps },
|
||||
{ FunctionNames.CubicBezier, ParseCubicBezier },
|
||||
};
|
||||
|
||||
public static ITimingFunction ParseTimingFunction(this StringSource source)
|
||||
public static ICssTimingFunctionValue ParseTimingFunction(this StringSource source)
|
||||
{
|
||||
var pos = source.Index;
|
||||
var result = default(ITimingFunction);
|
||||
var result = default(ICssTimingFunctionValue);
|
||||
var ident = source.ParseIdent();
|
||||
|
||||
if (ident != null)
|
||||
{
|
||||
if (source.Current == Symbols.RoundBracketOpen)
|
||||
{
|
||||
var function = default(Func<StringSource, ITimingFunction>);
|
||||
var function = default(Func<StringSource, ICssTimingFunctionValue>);
|
||||
|
||||
if (TimingFunctions.TryGetValue(ident, out function))
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ namespace AngleSharp.Css.Parser
|
|||
return result;
|
||||
}
|
||||
|
||||
private static ITimingFunction ParseSteps(StringSource source)
|
||||
private static ICssTimingFunctionValue ParseSteps(StringSource source)
|
||||
{
|
||||
var intervals = source.ParseInteger();
|
||||
var c = source.SkipGetSkip();
|
||||
|
@ -71,7 +71,7 @@ namespace AngleSharp.Css.Parser
|
|||
return null;
|
||||
}
|
||||
|
||||
private static ITimingFunction ParseCubicBezier(StringSource source)
|
||||
private static ICssTimingFunctionValue ParseCubicBezier(StringSource source)
|
||||
{
|
||||
var p1 = source.ParseNumber();
|
||||
var c1 = source.SkipGetSkip();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Parser
|
|||
|
||||
static class TransformParser
|
||||
{
|
||||
private static readonly Dictionary<String, Func<StringSource, ITransform>> TransformFunctions = new Dictionary<String, Func<StringSource, ITransform>>
|
||||
private static readonly Dictionary<String, Func<StringSource, ICssTransformFunctionValue>> TransformFunctions = new Dictionary<String, Func<StringSource, ICssTransformFunctionValue>>
|
||||
{
|
||||
{ FunctionNames.Skew, ParseSkew2d },
|
||||
{ FunctionNames.SkewX, ParseSkewX },
|
||||
|
@ -33,7 +33,7 @@ namespace AngleSharp.Css.Parser
|
|||
{ FunctionNames.Perspective, ParsePerspective },
|
||||
};
|
||||
|
||||
public static ITransform ParseTransform(this StringSource source)
|
||||
public static ICssTransformFunctionValue ParseTransform(this StringSource source)
|
||||
{
|
||||
var pos = source.Index;
|
||||
var ident = source.ParseIdent();
|
||||
|
@ -42,7 +42,7 @@ namespace AngleSharp.Css.Parser
|
|||
{
|
||||
if (source.Current == Symbols.RoundBracketOpen)
|
||||
{
|
||||
var function = default(Func<StringSource, ITransform>);
|
||||
var function = default(Func<StringSource, ICssTransformFunctionValue>);
|
||||
|
||||
if (TransformFunctions.TryGetValue(ident, out function))
|
||||
{
|
||||
|
@ -479,7 +479,7 @@ namespace AngleSharp.Css.Parser
|
|||
/// A perspective for 3D transformations.
|
||||
/// http://www.w3.org/TR/css3-transforms/#funcdef-perspective
|
||||
/// </summary>
|
||||
private static ITransform ParsePerspective(StringSource source)
|
||||
private static ICssTransformFunctionValue ParsePerspective(StringSource source)
|
||||
{
|
||||
var l = source.ParseLengthOrCalc();
|
||||
var f = source.SkipGetSkip();
|
||||
|
|
|
@ -872,13 +872,13 @@ namespace AngleSharp.Css
|
|||
private static IValueConverter FromParser<T>(Func<StringSource, T> converter)
|
||||
where T : class, ICssValue => new ClassValueConverter<T>(converter);
|
||||
|
||||
private static Func<StringSource, StringValue> FromString(Func<StringSource, String> converter) => source =>
|
||||
private static Func<StringSource, Label> FromString(Func<StringSource, String> converter) => source =>
|
||||
{
|
||||
var result = converter.Invoke(source);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
return new StringValue(result);
|
||||
return new Label(result);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace AngleSharp.Css.Values
|
|||
{ "threedshadow", new Color(136, 136, 136) },
|
||||
{ "window", new Color(255, 255, 255) },
|
||||
{ "windowframe", new Color(204, 204, 204) },
|
||||
{ "windowtext", new Color(0, 0, 0) }
|
||||
{ "windowtext", new Color(0, 0, 0) },
|
||||
};
|
||||
|
||||
#endregion
|
||||
|
@ -215,9 +215,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>The color with the given name or null.</returns>
|
||||
public static Color? GetColor(String name)
|
||||
{
|
||||
var color = default(Color);
|
||||
|
||||
if (TheColors.TryGetValue(name, out color))
|
||||
if (TheColors.TryGetValue(name, out Color color))
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS background definition.
|
||||
/// </summary>
|
||||
sealed class Background : ICssValue
|
||||
sealed class Background : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _layers;
|
||||
private readonly ICssValue _color;
|
|
@ -4,7 +4,7 @@ namespace AngleSharp.Css.Values
|
|||
using AngleSharp.Text;
|
||||
using System;
|
||||
|
||||
struct BackgroundLayer : ICssValue
|
||||
struct BackgroundLayer : ICssCompositeValue
|
||||
{
|
||||
public ICssValue Image;
|
||||
public Point? Position;
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS border image definition.
|
||||
/// </summary>
|
||||
struct BorderImage : ICssValue
|
||||
struct BorderImage : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using AngleSharp.Text;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the CSS border image slice definition.
|
||||
/// </summary>
|
||||
struct BorderImageSlice : ICssValue
|
||||
struct BorderImageSlice : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a border radius value.
|
||||
/// </summary>
|
||||
class BorderRadius : ICssValue
|
||||
class BorderRadius : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a calc add expression, i.e., a + b.
|
||||
/// </summary>
|
||||
class CalcAddExpression : ICssValue
|
||||
class CalcAddExpression : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _left;
|
||||
private readonly ICssValue _right;
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a calc division expression, i.e., a / b.
|
||||
/// </summary>
|
||||
class CalcDivExpression : ICssValue
|
||||
class CalcDivExpression : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _left;
|
||||
private readonly ICssValue _right;
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a calc multiplication expression, i.e., a * b.
|
||||
/// </summary>
|
||||
class CalcMulExpression : ICssValue
|
||||
class CalcMulExpression : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _left;
|
||||
private readonly ICssValue _right;
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a calc subtraction expression, i.e., a - b.
|
||||
/// </summary>
|
||||
class CalcSubExpression : ICssValue
|
||||
class CalcSubExpression : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _left;
|
||||
private readonly ICssValue _right;
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS cursor definition.
|
||||
/// </summary>
|
||||
class Cursor : ICssValue
|
||||
class Cursor : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue[] _definitions;
|
||||
private readonly ICssValue _cursor;
|
|
@ -1,12 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using AngleSharp.Text;
|
||||
using System;
|
||||
|
||||
struct CursorDefinition : ICssValue
|
||||
struct CursorDefinition : ICssCompositeValue
|
||||
{
|
||||
public IImageSource Source;
|
||||
public ICssImageValue Source;
|
||||
public Point? Position;
|
||||
|
||||
/// <summary>
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS font definition.
|
||||
/// </summary>
|
||||
class FontInfo : ICssValue
|
||||
class FontInfo : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// More information can be found at the W3C:
|
||||
/// http://dev.w3.org/csswg/css-images-3/#color-stop-syntax
|
||||
/// </summary>
|
||||
struct GradientStop : ICssValue
|
||||
struct GradientStop : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -9,7 +9,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS grid definition.
|
||||
/// </summary>
|
||||
class Grid : ICssValue
|
||||
class Grid : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS grid template definition.
|
||||
/// </summary>
|
||||
class GridTemplate : ICssValue
|
||||
class GridTemplate : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -94,8 +94,8 @@ namespace AngleSharp.Css.Values
|
|||
|
||||
return rows;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS image repeat definition.
|
||||
/// </summary>
|
||||
struct ImageRepeats : ICssValue
|
||||
struct ImageRepeats : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _horizontal;
|
||||
private readonly ICssValue _vertical;
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a point value consisting of two distances.
|
||||
/// </summary>
|
||||
struct Point : IEquatable<Point>, ICssValue
|
||||
struct Point : IEquatable<Point>, ICssCompositeValue
|
||||
{
|
||||
#region Basic values
|
||||
|
||||
|
@ -153,10 +153,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="a">The left point.</param>
|
||||
/// <param name="b">The right point.</param>
|
||||
/// <returns>True if both points are equal, otherwise false.</returns>
|
||||
public static Boolean operator ==(Point a, Point b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
public static Boolean operator ==(Point a, Point b) => a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks the inequality of the two given points.
|
||||
|
@ -164,20 +161,14 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="a">The left point.</param>
|
||||
/// <param name="b">The right point.</param>
|
||||
/// <returns>True if both points are not equal, otherwise false.</returns>
|
||||
public static Boolean operator !=(Point a, Point b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
public static Boolean operator !=(Point a, Point b) => !a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if both points are actually equal.
|
||||
/// </summary>
|
||||
/// <param name="other">The other point to compare to.</param>
|
||||
/// <returns>True if both points are equal, otherwise false.</returns>
|
||||
public Boolean Equals(Point other)
|
||||
{
|
||||
return _x.Equals(other._x) && _y.Equals(other._y);
|
||||
}
|
||||
public Boolean Equals(Point other) => _x.Equals(other._x) && _y.Equals(other._y);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS origin definition.
|
||||
/// </summary>
|
||||
class Point3 : ICssValue
|
||||
class Point3 : ICssCompositeValue
|
||||
{
|
||||
private readonly ICssValue _x;
|
||||
private readonly ICssValue _y;
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// The shadow class for holding information about a box or text-shadow.
|
||||
/// </summary>
|
||||
class Shadow : ICssValue
|
||||
class Shadow : ICssCompositeValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -9,7 +9,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents a cubic-bezier timing-function object.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/timing-function
|
||||
/// </summary>
|
||||
class CubicBezierTimingFunction : ITimingFunction, IEquatable<CubicBezierTimingFunction>
|
||||
class CubicBezierTimingFunction : ICssTimingFunctionValue, IEquatable<CubicBezierTimingFunction>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -145,10 +145,8 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="other">The cubic bezier to compare to.</param>
|
||||
/// <returns>True if both have the same parameters, otherwise false.</returns>
|
||||
public Boolean Equals(CubicBezierTimingFunction other)
|
||||
{
|
||||
return _x1 == other._x1 && _x2 == other._x2 && _y1 == other._y1 && _y2 == other._y2;
|
||||
}
|
||||
public Boolean Equals(CubicBezierTimingFunction other) =>
|
||||
_x1 == other._x1 && _x2 == other._x2 && _y1 == other._y1 && _y2 == other._y2;
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -16,7 +16,7 @@ namespace AngleSharp.Css.Values
|
|||
|
||||
public String Name => CssKeywords.Format;
|
||||
|
||||
public ICssValue[] Arguments => new[] { new StringValue(_fontFormat) };
|
||||
public ICssValue[] Arguments => new[] { new Label(_fontFormat) };
|
||||
|
||||
public String CssText => Name.CssFunction(Arguments.Join(", "));
|
||||
}
|
|
@ -9,7 +9,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents a linear gradient:
|
||||
/// http://dev.w3.org/csswg/css-images-3/#linear-gradients
|
||||
/// </summary>
|
||||
class LinearGradient : IGradient, ICssFunctionValue
|
||||
class LinearGradient : ICssGradientFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -16,7 +16,7 @@ namespace AngleSharp.Css.Values
|
|||
|
||||
public String Name => CssKeywords.Local;
|
||||
|
||||
public ICssValue[] Arguments => new[] { new StringValue(_fontName) };
|
||||
public ICssValue[] Arguments => new[] { new Label(_fontName) };
|
||||
|
||||
public String CssText => Name.CssFunction(Arguments.Join(", "));
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the matrix3d transformation.
|
||||
/// </summary>
|
||||
class MatrixTransform : ITransform, ICssFunctionValue
|
||||
class MatrixTransform : ICssTransformFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the distance transformation.
|
||||
/// </summary>
|
||||
class PerspectiveTransform : ITransform, ICssFunctionValue
|
||||
class PerspectiveTransform : ICssTransformFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -11,7 +11,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents a radial gradient:
|
||||
/// http://dev.w3.org/csswg/css-images-3/#radial-gradients
|
||||
/// </summary>
|
||||
class RadialGradient : IGradient, ICssFunctionValue
|
||||
class RadialGradient : ICssGradientFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -94,7 +94,7 @@ namespace AngleSharp.Css.Values
|
|||
}
|
||||
}
|
||||
|
||||
args.Add(new CssAnyValue(String.Join(" ", new[]
|
||||
args.Add(new AnyValue(String.Join(" ", new[]
|
||||
{
|
||||
_circle ? CssKeywords.Circle : CssKeywords.Ellipse,
|
||||
size,
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the rotate3d transformation.
|
||||
/// </summary>
|
||||
class RotateTransform : ITransform, ICssFunctionValue
|
||||
class RotateTransform : ICssTransformFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the scale3d transformation.
|
||||
/// </summary>
|
||||
class ScaleTransform : ITransform, ICssFunctionValue
|
||||
class ScaleTransform : ICssTransformFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -136,10 +136,8 @@ namespace AngleSharp.Css.Values
|
|||
/// Computes the matrix for the given transformation.
|
||||
/// </summary>
|
||||
/// <returns>The transformation matrix representation.</returns>
|
||||
public TransformMatrix ComputeMatrix()
|
||||
{
|
||||
return new TransformMatrix(_sx, 0f, 0f, 0f, _sy, 0f, 0f, 0f, _sz, 0f, 0f, 0f, 0f, 0f, 0f);
|
||||
}
|
||||
public TransformMatrix ComputeMatrix() =>
|
||||
new TransformMatrix(_sx, 0f, 0f, 0f, _sy, 0f, 0f, 0f, _sz, 0f, 0f, 0f, 0f, 0f, 0f);
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the skew transformation.
|
||||
/// </summary>
|
||||
class SkewTransform : ITransform, ICssFunctionValue
|
||||
class SkewTransform : ICssTransformFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -10,7 +10,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents a steps timing-function object.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/timing-function
|
||||
/// </summary>
|
||||
class StepsTimingFunction : ITimingFunction
|
||||
class StepsTimingFunction : ICssTimingFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -50,8 +50,10 @@ namespace AngleSharp.Css.Values
|
|||
{
|
||||
get
|
||||
{
|
||||
var args = new List<ICssValue>();
|
||||
args.Add(new Length(_intervals, Length.Unit.None));
|
||||
var args = new List<ICssValue>
|
||||
{
|
||||
new Length(_intervals, Length.Unit.None),
|
||||
};
|
||||
|
||||
if (_start)
|
||||
{
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the translate3d transformation.
|
||||
/// </summary>
|
||||
class TranslateTransform : ITransform, ICssFunctionValue
|
||||
class TranslateTransform : ICssTransformFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -69,11 +69,11 @@ namespace AngleSharp.Css.Values
|
|||
/// Gets the arguments.
|
||||
/// </summary>
|
||||
public ICssValue[] Arguments => new[]
|
||||
{
|
||||
_x,
|
||||
_y,
|
||||
_z
|
||||
};
|
||||
{
|
||||
_x,
|
||||
_y,
|
||||
_z
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CSS text representation.
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents an URL object.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/uri
|
||||
/// </summary>
|
||||
class UrlReference : IImageSource, ICssFunctionValue
|
||||
class UrlReference : ICssImageValue, ICssFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Gets the arguments.
|
||||
/// </summary>
|
||||
public ICssValue[] Arguments => new[] { new StringValue(_path) };
|
||||
public ICssValue[] Arguments => new[] { new Label(_path) };
|
||||
|
||||
/// <summary>
|
||||
/// Gets the CSS text representation.
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS var replacement.
|
||||
/// </summary>
|
||||
class VarReference : ICssValue, ICssFunctionValue
|
||||
class VarReference : ICssFunctionValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -46,12 +46,14 @@ namespace AngleSharp.Css.Values
|
|||
{
|
||||
get
|
||||
{
|
||||
var list = new List<ICssValue>();
|
||||
list.Add(new Identifier(_variableName));
|
||||
var list = new List<ICssValue>
|
||||
{
|
||||
new Identifier(_variableName),
|
||||
};
|
||||
|
||||
if (_defaultValue != null)
|
||||
{
|
||||
list.Add(new CssAnyValue(_defaultValue));
|
||||
list.Add(new AnyValue(_defaultValue));
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
|
@ -76,8 +78,10 @@ namespace AngleSharp.Css.Values
|
|||
get
|
||||
{
|
||||
var fn = FunctionNames.Var;
|
||||
var args = new List<String>();
|
||||
args.Add(_variableName);
|
||||
var args = new List<String>
|
||||
{
|
||||
_variableName,
|
||||
};
|
||||
|
||||
if (!String.IsNullOrEmpty(_defaultValue))
|
||||
{
|
|
@ -0,0 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a composition of CSS values.
|
||||
/// </summary>
|
||||
public interface ICssCompositeValue : ICssValue
|
||||
{
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS value using a function call.
|
||||
/// </summary>
|
||||
interface ICssFunctionValue : ICssValue
|
||||
public interface ICssFunctionValue : ICssValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name of the function.
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// The common interface for all CSS gradients.
|
||||
/// </summary>
|
||||
interface IGradient : IImageSource
|
||||
interface ICssGradientFunctionValue : ICssImageValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an enumeration of all stops.
|
|
@ -1,12 +1,10 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
|
||||
/// <summary>
|
||||
/// Basic interface for all image sources
|
||||
/// (linear-gradient, radial-gradient, URL, solid, ...).
|
||||
/// </summary>
|
||||
interface IImageSource : ICssValue
|
||||
interface ICssImageValue : ICssFunctionValue
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a multiple CSS value holder.
|
||||
/// </summary>
|
||||
public interface ICssMultipleValue : ICssValue
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a primitive CSS value.
|
||||
/// </summary>
|
||||
public interface ICssPrimitiveValue : ICssValue
|
||||
{
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a value that needs to be evaluated at runtime.
|
||||
/// </summary>
|
||||
interface ICssRawValue : ICssValue
|
||||
public interface ICssRawValue : ICssValue
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a general timing function.
|
||||
/// </summary>
|
||||
interface ITimingFunction : ICssFunctionValue
|
||||
interface ICssTimingFunctionValue : ICssFunctionValue
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
|
||||
/// <summary>
|
||||
/// Functionality for computing transformation.
|
||||
/// </summary>
|
||||
interface ITransform : ICssValue
|
||||
interface ICssTransformFunctionValue : ICssFunctionValue
|
||||
{
|
||||
/// <summary>
|
||||
/// Computes the matrix for the given transformation.
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents the CSS counters definition.
|
||||
/// </summary>
|
||||
class Counters : ICssValue
|
||||
class Counters : ICssMultipleValue
|
||||
{
|
||||
private readonly ICssValue[] _counters;
|
||||
|
|
@ -10,7 +10,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS value list.
|
||||
/// </summary>
|
||||
class CssListValue : ICssValue, IEnumerable<ICssValue>
|
||||
class CssListValue : ICssMultipleValue, IEnumerable<ICssValue>
|
||||
{
|
||||
private readonly ICssValue[] _items;
|
||||
|
||||
|
@ -33,14 +33,9 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
public String CssText => _items.Join(", ");
|
||||
|
||||
IEnumerator<ICssValue> IEnumerable<ICssValue>.GetEnumerator()
|
||||
{
|
||||
return _items.AsEnumerable().GetEnumerator();
|
||||
}
|
||||
IEnumerator<ICssValue> IEnumerable<ICssValue>.GetEnumerator() =>
|
||||
_items.AsEnumerable().GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() => _items.GetEnumerator();
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a tuple of CSS values.
|
||||
/// </summary>
|
||||
class CssTupleValue : ICssValue, IEnumerable<ICssValue>
|
||||
class CssTupleValue : ICssMultipleValue, IEnumerable<ICssValue>
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -55,15 +55,10 @@ namespace AngleSharp.Css.Values
|
|||
|
||||
#region Methods
|
||||
|
||||
IEnumerator<ICssValue> IEnumerable<ICssValue>.GetEnumerator()
|
||||
{
|
||||
return _items.AsEnumerable().GetEnumerator();
|
||||
}
|
||||
IEnumerator<ICssValue> IEnumerable<ICssValue>.GetEnumerator() =>
|
||||
_items.AsEnumerable().GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return _items.GetEnumerator();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() => _items.GetEnumerator();
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a periodic CSS value.
|
||||
/// </summary>
|
||||
class Periodic<T> : ICssValue
|
||||
class Periodic<T> : ICssMultipleValue
|
||||
where T : ICssValue
|
||||
{
|
||||
#region Fields
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents an angle object.
|
||||
/// https://developer.mozilla.org/en-US/docs/Web/CSS/angle
|
||||
/// </summary>
|
||||
struct Angle : IEquatable<Angle>, IComparable<Angle>, ICssValue
|
||||
struct Angle : IEquatable<Angle>, IComparable<Angle>, ICssPrimitiveValue
|
||||
{
|
||||
#region Basic angles
|
||||
|
||||
|
@ -121,10 +121,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two angles.
|
||||
/// </summary>
|
||||
public static Boolean operator >(Angle a, Angle b)
|
||||
{
|
||||
return a.CompareTo(b) == 1;
|
||||
}
|
||||
public static Boolean operator >(Angle a, Angle b) => a.CompareTo(b) == 1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the magnitude of two angles.
|
||||
|
@ -138,20 +135,14 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two angles.
|
||||
/// </summary>
|
||||
public static Boolean operator <(Angle a, Angle b)
|
||||
{
|
||||
return a.CompareTo(b) == -1;
|
||||
}
|
||||
public static Boolean operator <(Angle a, Angle b) => a.CompareTo(b) == -1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current angle against the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The angle to compare to.</param>
|
||||
/// <returns>The result of the comparison.</returns>
|
||||
public Int32 CompareTo(Angle other)
|
||||
{
|
||||
return ToRadian().CompareTo(other.ToRadian());
|
||||
}
|
||||
public Int32 CompareTo(Angle other) => ToRadian().CompareTo(other.ToRadian());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -165,8 +156,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>True if successful, otherwise false.</returns>
|
||||
public static Boolean TryParse(String s, out Angle result)
|
||||
{
|
||||
var value = default(Double);
|
||||
var unit = GetUnit(s.CssUnit(out value));
|
||||
var unit = GetUnit(s.CssUnit(out double value));
|
||||
|
||||
if (unit != Unit.None)
|
||||
{
|
||||
|
@ -244,10 +234,7 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="other">The angle to compare with.</param>
|
||||
/// <returns>True if both represent the same angle in rad.</returns>
|
||||
public Boolean Equals(Angle other)
|
||||
{
|
||||
return ToRadian() == other.ToRadian();
|
||||
}
|
||||
public Boolean Equals(Angle other) => ToRadian() == other.ToRadian();
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -287,18 +274,12 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Checks for equality of two angles.
|
||||
/// </summary>
|
||||
public static Boolean operator ==(Angle a, Angle b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
public static Boolean operator ==(Angle a, Angle b) => a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks for inequality of two angles.
|
||||
/// </summary>
|
||||
public static Boolean operator !=(Angle a, Angle b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
public static Boolean operator !=(Angle a, Angle b) => !a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -321,10 +302,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Returns a hash code that defines the current angle.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return (Int32)_value;
|
||||
}
|
||||
public override Int32 GetHashCode() => (Int32)_value;
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -6,7 +6,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS background size definition.
|
||||
/// </summary>
|
||||
struct BackgroundSize : IEquatable<BackgroundSize>, ICssValue
|
||||
struct BackgroundSize : IEquatable<BackgroundSize>, ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -94,10 +94,8 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="other">The other background size.</param>
|
||||
/// <returns>True if both are equivalent, otherwise false.</returns>
|
||||
public Boolean Equals(BackgroundSize other)
|
||||
{
|
||||
return _mode == other._mode && _height == other._height && _width == other._width;
|
||||
}
|
||||
public Boolean Equals(BackgroundSize other) =>
|
||||
_mode == other._mode && _height == other._height && _width == other._width;
|
||||
|
||||
#endregion
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css;
|
||||
using AngleSharp.Css.Dom;
|
||||
using AngleSharp.Text;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
@ -11,7 +10,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Represents a color value.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Pack = 1, CharSet = CharSet.Unicode)]
|
||||
struct Color : IEquatable<Color>, IComparable<Color>, ICssValue
|
||||
struct Color : IEquatable<Color>, IComparable<Color>, ICssPrimitiveValue
|
||||
{
|
||||
#region Basic colors
|
||||
|
||||
|
@ -127,10 +126,8 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="b">The value for blue [0,255].</param>
|
||||
/// <param name="a">The value for alpha [0,1].</param>
|
||||
/// <returns>The CSS color value.</returns>
|
||||
public static Color FromRgba(Byte r, Byte g, Byte b, Double a)
|
||||
{
|
||||
return new Color(r, g, b, Normalize(a));
|
||||
}
|
||||
public static Color FromRgba(Byte r, Byte g, Byte b, Double a) =>
|
||||
new Color(r, g, b, Normalize(a));
|
||||
|
||||
/// <summary>
|
||||
/// Returns the color from the given primitives.
|
||||
|
@ -140,10 +137,8 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="b">The value for blue [0,1].</param>
|
||||
/// <param name="a">The value for alpha [0,1].</param>
|
||||
/// <returns>The CSS color value.</returns>
|
||||
public static Color FromRgba(Double r, Double g, Double b, Double a)
|
||||
{
|
||||
return new Color(Normalize(r), Normalize(g), Normalize(b), Normalize(a));
|
||||
}
|
||||
public static Color FromRgba(Double r, Double g, Double b, Double a) =>
|
||||
new Color(Normalize(r), Normalize(g), Normalize(b), Normalize(a));
|
||||
|
||||
/// <summary>
|
||||
/// Returns the gray color from the given value.
|
||||
|
@ -151,10 +146,8 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="number">The value for each component [0,255].</param>
|
||||
/// <param name="alpha">The value for alpha [0,1].</param>
|
||||
/// <returns>The CSS color value.</returns>
|
||||
public static Color FromGray(Byte number, Double alpha = 1.0)
|
||||
{
|
||||
return new Color(number, number, number, Normalize(alpha));
|
||||
}
|
||||
public static Color FromGray(Byte number, Double alpha = 1.0) =>
|
||||
new Color(number, number, number, Normalize(alpha));
|
||||
|
||||
/// <summary>
|
||||
/// Returns the gray color from the given value.
|
||||
|
@ -162,20 +155,15 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="value">The value for each component [0,1].</param>
|
||||
/// <param name="alpha">The value for alpha [0,1].</param>
|
||||
/// <returns>The CSS color value.</returns>
|
||||
public static Color FromGray(Double value, Double alpha = 1.0)
|
||||
{
|
||||
return FromGray(Normalize(value), alpha);
|
||||
}
|
||||
public static Color FromGray(Double value, Double alpha = 1.0) =>
|
||||
FromGray(Normalize(value), alpha);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the color with the given name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the color.</param>
|
||||
/// <returns>The CSS color value.</returns>
|
||||
public static Color? FromName(String name)
|
||||
{
|
||||
return Colors.GetColor(name);
|
||||
}
|
||||
public static Color? FromName(String name) => Colors.GetColor(name);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the color from the given primitives without any alpha.
|
||||
|
@ -184,10 +172,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="g">The value for green [0,255].</param>
|
||||
/// <param name="b">The value for blue [0,255].</param>
|
||||
/// <returns>The CSS color value.</returns>
|
||||
public static Color FromRgb(Byte r, Byte g, Byte b)
|
||||
{
|
||||
return new Color(r, g, b);
|
||||
}
|
||||
public static Color FromRgb(Byte r, Byte g, Byte b) => new Color(r, g, b);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the color from the given hex string.
|
||||
|
@ -303,10 +288,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="s">The saturation [0,1].</param>
|
||||
/// <param name="l">The light value [0,1].</param>
|
||||
/// <returns>The CSS color.</returns>
|
||||
public static Color FromHsl(Double h, Double s, Double l)
|
||||
{
|
||||
return FromHsla(h, s, l, 1.0);
|
||||
}
|
||||
public static Color FromHsl(Double h, Double s, Double l) => FromHsla(h, s, l, 1.0);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the color that represents the given HSL values.
|
||||
|
@ -461,10 +443,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="a">The first color to use.</param>
|
||||
/// <param name="b">The second color to use.</param>
|
||||
/// <returns>True if both colors are equal, otherwise false.</returns>
|
||||
public static Boolean operator ==(Color a, Color b)
|
||||
{
|
||||
return a._hashcode == b._hashcode;
|
||||
}
|
||||
public static Boolean operator ==(Color a, Color b) => a._hashcode == b._hashcode;
|
||||
|
||||
/// <summary>
|
||||
/// Compares two colors and returns a boolean indicating if the two do not match.
|
||||
|
@ -472,20 +451,14 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="a">The first color to use.</param>
|
||||
/// <param name="b">The second color to use.</param>
|
||||
/// <returns>True if both colors are not equal, otherwise false.</returns>
|
||||
public static Boolean operator !=(Color a, Color b)
|
||||
{
|
||||
return a._hashcode != b._hashcode;
|
||||
}
|
||||
public static Boolean operator !=(Color a, Color b) => a._hashcode != b._hashcode;
|
||||
|
||||
/// <summary>
|
||||
/// Checks two colors for equality.
|
||||
/// </summary>
|
||||
/// <param name="other">The other color.</param>
|
||||
/// <returns>True if both colors or equal, otherwise false.</returns>
|
||||
public Boolean Equals(Color other)
|
||||
{
|
||||
return this._hashcode == other._hashcode;
|
||||
}
|
||||
public Boolean Equals(Color other) => _hashcode == other._hashcode;
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -504,19 +477,13 @@ namespace AngleSharp.Css.Values
|
|||
return false;
|
||||
}
|
||||
|
||||
Int32 IComparable<Color>.CompareTo(Color other)
|
||||
{
|
||||
return _hashcode - other._hashcode;
|
||||
}
|
||||
Int32 IComparable<Color>.CompareTo(Color other) => _hashcode - other._hashcode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code that defines the current color.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return _hashcode;
|
||||
}
|
||||
public override Int32 GetHashCode() => _hashcode;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -529,10 +496,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="above">The first color (above) with transparency.</param>
|
||||
/// <param name="below">The second color (below the first one) without transparency.</param>
|
||||
/// <returns>The outcome in the crossing section.</returns>
|
||||
public static Color Mix(Color above, Color below)
|
||||
{
|
||||
return Mix(above.Alpha, above, below);
|
||||
}
|
||||
public static Color Mix(Color above, Color below) => Mix(above.Alpha, above, below);
|
||||
|
||||
/// <summary>
|
||||
/// Mixes two colors using alpha compositing as described here:
|
||||
|
@ -555,10 +519,8 @@ namespace AngleSharp.Css.Values
|
|||
|
||||
#region Helpers
|
||||
|
||||
private static Byte Normalize(Double value)
|
||||
{
|
||||
return (Byte)Math.Max(Math.Min(Math.Truncate(256.0 * value), 255.0), 0.0);
|
||||
}
|
||||
private static Byte Normalize(Double value) =>
|
||||
(Byte)Math.Max(Math.Min(Math.Truncate(256.0 * value), 255.0), 0.0);
|
||||
|
||||
private static Double HueToRgb(Double m1, Double m2, Double h)
|
||||
{
|
|
@ -1,12 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a selected CSS enum value.
|
||||
/// </summary>
|
||||
class Constant<T> : ICssValue
|
||||
class Constant<T> : ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a CSS counter.
|
||||
/// </summary>
|
||||
struct CounterDefinition : ICssValue
|
||||
struct CounterDefinition : ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Sets a CSS counter.
|
||||
/// </summary>
|
||||
struct CounterValue : ICssValue
|
||||
struct CounterValue : ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a fractional value.
|
||||
/// </summary>
|
||||
struct Fraction : IEquatable<Fraction>, IComparable<Fraction>, ICssValue
|
||||
struct Fraction : IEquatable<Fraction>, IComparable<Fraction>, ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -78,8 +77,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>True if successful, otherwise false.</returns>
|
||||
public static Boolean TryParse(String s, out Fraction result)
|
||||
{
|
||||
var value = default(Double);
|
||||
var unit = GetUnit(s.CssUnit(out value));
|
||||
var unit = GetUnit(s.CssUnit(out double value));
|
||||
|
||||
if (unit != Unit.None)
|
||||
{
|
||||
|
@ -110,20 +108,14 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="unit">The unit to convert to.</param>
|
||||
/// <returns>The value in the given unit.</returns>
|
||||
public Double To(Unit unit)
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
public Double To(Unit unit) => _value;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the current resolution equals the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The given resolution to check for equality.</param>
|
||||
/// <returns>True if both are equal, otherwise false.</returns>
|
||||
public Boolean Equals(Fraction other)
|
||||
{
|
||||
return _value == other._value && _unit == other._unit;
|
||||
}
|
||||
public Boolean Equals(Fraction other) => _value == other._value && _unit == other._unit;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -153,10 +145,7 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="other">The fraction to compare to.</param>
|
||||
/// <returns>The result of the comparison.</returns>
|
||||
public Int32 CompareTo(Fraction other)
|
||||
{
|
||||
return _value.CompareTo(other._value);
|
||||
}
|
||||
public Int32 CompareTo(Fraction other) => _value.CompareTo(other._value);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -179,10 +168,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Returns a hash code that defines the current fraction.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return _value.GetHashCode();
|
||||
}
|
||||
public override Int32 GetHashCode() => _value.GetHashCode();
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a time value.
|
||||
/// </summary>
|
||||
struct Frequency : IEquatable<Frequency>, IComparable<Frequency>, ICssValue
|
||||
struct Frequency : IEquatable<Frequency>, IComparable<Frequency>, ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -85,10 +84,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two frequencies.
|
||||
/// </summary>
|
||||
public static Boolean operator >(Frequency a, Frequency b)
|
||||
{
|
||||
return a.CompareTo(b) == 1;
|
||||
}
|
||||
public static Boolean operator >(Frequency a, Frequency b) => a.CompareTo(b) == 1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the magnitude of two frequencies.
|
||||
|
@ -102,20 +98,14 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two frequencies.
|
||||
/// </summary>
|
||||
public static Boolean operator <(Frequency a, Frequency b)
|
||||
{
|
||||
return a.CompareTo(b) == -1;
|
||||
}
|
||||
public static Boolean operator <(Frequency a, Frequency b) => a.CompareTo(b) == -1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current frequency against the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The frequency to compare to.</param>
|
||||
/// <returns>The result of the comparison.</returns>
|
||||
public Int32 CompareTo(Frequency other)
|
||||
{
|
||||
return ToHertz().CompareTo(other.ToHertz());
|
||||
}
|
||||
public Int32 CompareTo(Frequency other) => ToHertz().CompareTo(other.ToHertz());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -129,8 +119,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>True if successful, otherwise false.</returns>
|
||||
public static Boolean TryParse(String s, out Frequency result)
|
||||
{
|
||||
var value = default(Double);
|
||||
var unit = GetUnit(s.CssUnit(out value));
|
||||
var unit = GetUnit(s.CssUnit(out double value));
|
||||
|
||||
if (unit != Unit.None)
|
||||
{
|
||||
|
@ -161,20 +150,14 @@ namespace AngleSharp.Css.Values
|
|||
/// Converts the value to Hz.
|
||||
/// </summary>
|
||||
/// <returns>The value in Hz.</returns>
|
||||
public Double ToHertz()
|
||||
{
|
||||
return _unit == Unit.Khz ? _value * 1000.0 : _value;
|
||||
}
|
||||
public Double ToHertz() => _unit == Unit.Khz ? _value * 1000.0 : _value;
|
||||
|
||||
/// <summary>
|
||||
/// Checks for equality with the other frequency.
|
||||
/// </summary>
|
||||
/// <param name="other">The frequency to compare to.</param>
|
||||
/// <returns>True if both frequencies are equal, otherwise false.</returns>
|
||||
public Boolean Equals(Frequency other)
|
||||
{
|
||||
return _value == other._value && _unit == other._unit;
|
||||
}
|
||||
public Boolean Equals(Frequency other) => _value == other._value && _unit == other._unit;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -206,18 +189,12 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Checks for equality of two frequencies.
|
||||
/// </summary>
|
||||
public static Boolean operator ==(Frequency a, Frequency b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
public static Boolean operator ==(Frequency a, Frequency b) => a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks for inequality of two frequencies.
|
||||
/// </summary>
|
||||
public static Boolean operator !=(Frequency a, Frequency b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
public static Boolean operator !=(Frequency a, Frequency b) => !a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -240,10 +217,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Returns a hash code that defines the current frequency.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return _value.GetHashCode();
|
||||
}
|
||||
public override Int32 GetHashCode() => _value.GetHashCode();
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a CSS identifier value.
|
||||
/// </summary>
|
||||
struct Identifier : ICssValue
|
||||
struct Identifier : ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using AngleSharp.Text;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a CSS string value.
|
||||
/// Represents a CSS label ("string") value.
|
||||
/// </summary>
|
||||
class StringValue : ICssValue
|
||||
class Label : ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -18,10 +17,10 @@ namespace AngleSharp.Css.Values
|
|||
#region ctor
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new CSS string value.
|
||||
/// Creates a new CSS label value.
|
||||
/// </summary>
|
||||
/// <param name="value">The string to represent.</param>
|
||||
public StringValue(String value)
|
||||
public Label(String value)
|
||||
{
|
||||
_value = value;
|
||||
}
|
||||
|
@ -31,7 +30,7 @@ namespace AngleSharp.Css.Values
|
|||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the string value.
|
||||
/// Gets the label value.
|
||||
/// </summary>
|
||||
public String Value => _value;
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents an absolute length value.
|
||||
/// </summary>
|
||||
struct Length : IEquatable<Length>, IComparable<Length>, ICssValue
|
||||
struct Length : IEquatable<Length>, IComparable<Length>, ICssPrimitiveValue
|
||||
{
|
||||
#region Basic lengths
|
||||
|
||||
|
@ -173,10 +172,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two lengths.
|
||||
/// </summary>
|
||||
public static Boolean operator >(Length a, Length b)
|
||||
{
|
||||
return a.CompareTo(b) == 1;
|
||||
}
|
||||
public static Boolean operator >(Length a, Length b) => a.CompareTo(b) == 1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the magnitude of two lengths.
|
||||
|
@ -190,10 +186,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two lengths.
|
||||
/// </summary>
|
||||
public static Boolean operator <(Length a, Length b)
|
||||
{
|
||||
return a.CompareTo(b) == -1;
|
||||
}
|
||||
public static Boolean operator <(Length a, Length b) => a.CompareTo(b) == -1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current length against the given one.
|
||||
|
@ -229,8 +222,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>True if successful, otherwise false.</returns>
|
||||
public static Boolean TryParse(String s, out Length result)
|
||||
{
|
||||
var value = default(Double);
|
||||
var unitString = s.CssUnit(out value);
|
||||
var unitString = s.CssUnit(out double value);
|
||||
var unit = GetUnit(unitString);
|
||||
|
||||
if (unit != Unit.None)
|
||||
|
@ -421,10 +413,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="a">The left length.</param>
|
||||
/// <param name="b">The right length.</param>
|
||||
/// <returns>True if both lengths are equal, otherwise false.</returns>
|
||||
public static Boolean operator ==(Length a, Length b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
public static Boolean operator ==(Length a, Length b) => a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks the inequality of the two given lengths.
|
||||
|
@ -432,21 +421,16 @@ namespace AngleSharp.Css.Values
|
|||
/// <param name="a">The left length.</param>
|
||||
/// <param name="b">The right length.</param>
|
||||
/// <returns>True if both lengths are not equal, otherwise false.</returns>
|
||||
public static Boolean operator !=(Length a, Length b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
public static Boolean operator !=(Length a, Length b) => !a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if both lengths are actually equal.
|
||||
/// </summary>
|
||||
/// <param name="other">The other length to compare to.</param>
|
||||
/// <returns>True if both lengths are equal, otherwise false.</returns>
|
||||
public Boolean Equals(Length other)
|
||||
{
|
||||
return (_value == other._value || (Double.IsNaN(_value) && Double.IsNaN(other._value))) &&
|
||||
(_value == 0.0 || _unit == other._unit);
|
||||
}
|
||||
public Boolean Equals(Length other) =>
|
||||
(_value == other._value || (Double.IsNaN(_value) && Double.IsNaN(other._value))) &&
|
||||
(_value == 0.0 || _unit == other._unit);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -469,10 +453,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Returns a hash code that defines the current length.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return _value.GetHashCode();
|
||||
}
|
||||
public override Int32 GetHashCode() => _value.GetHashCode();
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a CSS line names definition.
|
||||
/// </summary>
|
||||
class LineNames : ICssValue
|
||||
class LineNames : ICssPrimitiveValue
|
||||
{
|
||||
private readonly String[] _names;
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using AngleSharp.Text;
|
||||
using System;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a CSS quote.
|
||||
/// </summary>
|
||||
struct Quote : ICssValue
|
||||
struct Quote : ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
|
@ -1,13 +1,12 @@
|
|||
namespace AngleSharp.Css.Values
|
||||
{
|
||||
using AngleSharp.Css.Dom;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a resolution value.
|
||||
/// </summary>
|
||||
struct Resolution : IEquatable<Resolution>, IComparable<Resolution>, ICssValue
|
||||
struct Resolution : IEquatable<Resolution>, IComparable<Resolution>, ICssPrimitiveValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -84,8 +83,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>True if successful, otherwise false.</returns>
|
||||
public static Boolean TryParse(String s, out Resolution result)
|
||||
{
|
||||
var value = default(Double);
|
||||
var unit = GetUnit(s.CssUnit(out value));
|
||||
var unit = GetUnit(s.CssUnit(out double value));
|
||||
|
||||
if (unit != Unit.None)
|
||||
{
|
||||
|
@ -157,10 +155,7 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="other">The given resolution to check for equality.</param>
|
||||
/// <returns>True if both are equal, otherwise false.</returns>
|
||||
public Boolean Equals(Resolution other)
|
||||
{
|
||||
return _value == other._value && _unit == other._unit;
|
||||
}
|
||||
public Boolean Equals(Resolution other) => _value == other._value && _unit == other._unit;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -198,10 +193,7 @@ namespace AngleSharp.Css.Values
|
|||
/// </summary>
|
||||
/// <param name="other">The resolution to compare to.</param>
|
||||
/// <returns>The result of the comparison.</returns>
|
||||
public Int32 CompareTo(Resolution other)
|
||||
{
|
||||
return ToDotsPerPixel().CompareTo(other.ToDotsPerPixel());
|
||||
}
|
||||
public Int32 CompareTo(Resolution other) => ToDotsPerPixel().CompareTo(other.ToDotsPerPixel());
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -224,10 +216,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Returns a hash code that defines the current resolution.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return _value.GetHashCode();
|
||||
}
|
||||
public override Int32 GetHashCode() => _value.GetHashCode();
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -7,7 +7,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents a time value.
|
||||
/// </summary>
|
||||
struct Time : IEquatable<Time>, IComparable<Time>, ICssValue
|
||||
struct Time : IEquatable<Time>, IComparable<Time>, ICssPrimitiveValue
|
||||
{
|
||||
#region Basic times
|
||||
|
||||
|
@ -94,10 +94,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two times.
|
||||
/// </summary>
|
||||
public static Boolean operator >(Time a, Time b)
|
||||
{
|
||||
return a.CompareTo(b) == 1;
|
||||
}
|
||||
public static Boolean operator >(Time a, Time b) => a.CompareTo(b) == 1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the magnitude of two times.
|
||||
|
@ -111,20 +108,14 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Compares the magnitude of two times.
|
||||
/// </summary>
|
||||
public static Boolean operator <(Time a, Time b)
|
||||
{
|
||||
return a.CompareTo(b) == -1;
|
||||
}
|
||||
public static Boolean operator <(Time a, Time b) => a.CompareTo(b) == -1;
|
||||
|
||||
/// <summary>
|
||||
/// Compares the current time against the given one.
|
||||
/// </summary>
|
||||
/// <param name="other">The time to compare to.</param>
|
||||
/// <returns>The result of the comparison.</returns>
|
||||
public Int32 CompareTo(Time other)
|
||||
{
|
||||
return ToMilliseconds().CompareTo(other.ToMilliseconds());
|
||||
}
|
||||
public Int32 CompareTo(Time other) => ToMilliseconds().CompareTo(other.ToMilliseconds());
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -138,8 +129,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <returns>True if successful, otherwise false.</returns>
|
||||
public static Boolean TryParse(String s, out Time result)
|
||||
{
|
||||
var value = default(Double);
|
||||
var unit = GetUnit(s.CssUnit(out value));
|
||||
var unit = GetUnit(s.CssUnit(out double value));
|
||||
|
||||
if (unit != Unit.None)
|
||||
{
|
||||
|
@ -170,20 +160,14 @@ namespace AngleSharp.Css.Values
|
|||
/// Converts the value to milliseconds.
|
||||
/// </summary>
|
||||
/// <returns>The number of milliseconds.</returns>
|
||||
public Double ToMilliseconds()
|
||||
{
|
||||
return _unit == Unit.S ? _value * 1000.0 : _value;
|
||||
}
|
||||
public Double ToMilliseconds() => _unit == Unit.S ? _value * 1000.0 : _value;
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the current time is equal to the other time.
|
||||
/// </summary>
|
||||
/// <param name="other">The time to compare to.</param>
|
||||
/// <returns>True if both represent the same value.</returns>
|
||||
public Boolean Equals(Time other)
|
||||
{
|
||||
return ToMilliseconds() == other.ToMilliseconds();
|
||||
}
|
||||
public Boolean Equals(Time other) => ToMilliseconds() == other.ToMilliseconds();
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -215,18 +199,12 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Checks for equality of two times.
|
||||
/// </summary>
|
||||
public static Boolean operator ==(Time a, Time b)
|
||||
{
|
||||
return a.Equals(b);
|
||||
}
|
||||
public static Boolean operator ==(Time a, Time b) => a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Checks for inequality of two times.
|
||||
/// </summary>
|
||||
public static Boolean operator !=(Time a, Time b)
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
public static Boolean operator !=(Time a, Time b) => !a.Equals(b);
|
||||
|
||||
/// <summary>
|
||||
/// Tests if another object is equal to this object.
|
||||
|
@ -249,10 +227,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Returns a hash code that defines the current time.
|
||||
/// </summary>
|
||||
/// <returns>The integer value of the hashcode.</returns>
|
||||
public override Int32 GetHashCode()
|
||||
{
|
||||
return _value.GetHashCode();
|
||||
}
|
||||
public override Int32 GetHashCode() => _value.GetHashCode();
|
||||
|
||||
#endregion
|
||||
}
|
|
@ -5,7 +5,7 @@ namespace AngleSharp.Css.Values
|
|||
/// <summary>
|
||||
/// Represents an unknown (any) value.
|
||||
/// </summary>
|
||||
class CssAnyValue : ICssRawValue
|
||||
class AnyValue : ICssRawValue
|
||||
{
|
||||
#region Fields
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace AngleSharp.Css.Values
|
|||
/// Creates a new unknown value with the given literal content.
|
||||
/// </summary>
|
||||
/// <param name="text">The serialized value representation..</param>
|
||||
public CssAnyValue(String text)
|
||||
public AnyValue(String text)
|
||||
{
|
||||
_text = text;
|
||||
}
|
|
@ -174,7 +174,7 @@ namespace AngleSharp.Css
|
|||
/// <returns>True if all elements are equal, otherwise false.</returns>
|
||||
public Boolean Equals(TransformMatrix other)
|
||||
{
|
||||
var A = this._matrix;
|
||||
var A = _matrix;
|
||||
var B = other._matrix;
|
||||
|
||||
for (var i = 0; i < 4; i++)
|
||||
|
@ -200,11 +200,7 @@ namespace AngleSharp.Css
|
|||
/// </summary>
|
||||
/// <param name="obj">The object to test with.</param>
|
||||
/// <returns>True if the two objects are equal, otherwise false.</returns>
|
||||
public override Boolean Equals(Object obj)
|
||||
{
|
||||
var other = obj as TransformMatrix;
|
||||
return other != null ? Equals(other) : false;
|
||||
}
|
||||
public override Boolean Equals(Object obj) => obj is TransformMatrix other ? Equals(other) : false;
|
||||
|
||||
/// <summary>
|
||||
/// Returns a hash code that defines the current length.
|
||||
|
|
Загрузка…
Ссылка в новой задаче