OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> | 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. |
4 * All rights reserved. | 4 * All rights reserved. |
5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 5 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> | 6 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
7 * Copyright (C) 2011 Sencha, Inc. All rights reserved. | 7 * Copyright (C) 2011 Sencha, Inc. All rights reserved. |
8 * Copyright (C) 2015 Google Inc. All rights reserved. | 8 * Copyright (C) 2015 Google Inc. All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1646 if (show_right) | 1646 if (show_right) |
1647 list->Append(*right_value); | 1647 list->Append(*right_value); |
1648 if (show_bottom) | 1648 if (show_bottom) |
1649 list->Append(*bottom_value); | 1649 list->Append(*bottom_value); |
1650 if (show_left) | 1650 if (show_left) |
1651 list->Append(*left_value); | 1651 list->Append(*left_value); |
1652 | 1652 |
1653 return list; | 1653 return list; |
1654 } | 1654 } |
1655 | 1655 |
1656 static CSSValueList* ValuesForInlineBlockShorthand( | |
1657 const StylePropertyShorthand& shorthand, | |
1658 const ComputedStyle& style, | |
1659 const LayoutObject* layout_object, | |
1660 Node* styled_node, | |
1661 bool allow_visited_style) { | |
1662 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); | |
majidvp
2017/06/13 19:20:53
Does this need to be a CSSValueList or can we just
sunyunjia
2017/06/14 18:36:20
Done.
| |
1663 // Assume the properties are in the usual order top, right, bottom, left. | |
1664 const CSSValue* start_value = ComputedStyleCSSValueMapping::Get( | |
1665 shorthand.properties()[0], style, layout_object, styled_node, | |
1666 allow_visited_style); | |
1667 const CSSValue* end_value = ComputedStyleCSSValueMapping::Get( | |
1668 shorthand.properties()[1], style, layout_object, styled_node, | |
1669 allow_visited_style); | |
1670 | |
1671 // Both 2 properties must be specified. | |
majidvp
2017/06/13 19:20:53
nit: 2 is redundant.
sunyunjia
2017/06/14 18:36:20
Done.
| |
1672 if (!start_value || !end_value) | |
1673 return nullptr; | |
1674 | |
1675 bool show_end = !DataEquivalent(start_value, end_value); | |
1676 | |
1677 list->Append(*start_value); | |
1678 if (show_end) | |
1679 list->Append(*end_value); | |
1680 | |
1681 return list; | |
1682 } | |
1683 | |
1656 static CSSValueList* ValueForBorderRadiusShorthand(const ComputedStyle& style) { | 1684 static CSSValueList* ValueForBorderRadiusShorthand(const ComputedStyle& style) { |
1657 CSSValueList* list = CSSValueList::CreateSlashSeparated(); | 1685 CSSValueList* list = CSSValueList::CreateSlashSeparated(); |
1658 | 1686 |
1659 bool show_horizontal_bottom_left = style.BorderTopRightRadius().Width() != | 1687 bool show_horizontal_bottom_left = style.BorderTopRightRadius().Width() != |
1660 style.BorderBottomLeftRadius().Width(); | 1688 style.BorderBottomLeftRadius().Width(); |
1661 bool show_horizontal_bottom_right = | 1689 bool show_horizontal_bottom_right = |
1662 show_horizontal_bottom_left || (style.BorderBottomRightRadius().Width() != | 1690 show_horizontal_bottom_left || (style.BorderBottomRightRadius().Width() != |
1663 style.BorderTopLeftRadius().Width()); | 1691 style.BorderTopLeftRadius().Width()); |
1664 bool show_horizontal_top_right = | 1692 bool show_horizontal_top_right = |
1665 show_horizontal_bottom_right || (style.BorderTopRightRadius().Width() != | 1693 show_horizontal_bottom_right || (style.BorderTopRightRadius().Width() != |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1923 list->Append(*caps_value); | 1951 list->Append(*caps_value); |
1924 | 1952 |
1925 list->Append(*ValueForFontWeight(style)); | 1953 list->Append(*ValueForFontWeight(style)); |
1926 list->Append(*ValueForFontStretch(style)); | 1954 list->Append(*ValueForFontStretch(style)); |
1927 list->Append(*size_and_line_height); | 1955 list->Append(*size_and_line_height); |
1928 list->Append(*ValueForFontFamily(style)); | 1956 list->Append(*ValueForFontFamily(style)); |
1929 | 1957 |
1930 return list; | 1958 return list; |
1931 } | 1959 } |
1932 | 1960 |
1933 static CSSValue* ValueForScrollSnapDestination(const LengthPoint& destination, | 1961 static CSSValue* ValueForScrollSnapType(const ScrollSnapType& type, |
1934 const ComputedStyle& style) { | 1962 const ComputedStyle& style) { |
1935 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); | 1963 if (type.axis != kSnapAxisNone) { |
1936 list->Append(*ZoomAdjustedPixelValueForLength(destination.X(), style)); | 1964 return CSSValuePair::Create(CSSIdentifierValue::Create(type.axis), |
1937 list->Append(*ZoomAdjustedPixelValueForLength(destination.Y(), style)); | 1965 CSSIdentifierValue::Create(type.strictness), |
1938 return list; | 1966 CSSValuePair::kDropIdenticalValues); |
1939 } | |
1940 | |
1941 static CSSValue* ValueForScrollSnapPoints(const ScrollSnapPoints& points, | |
1942 const ComputedStyle& style) { | |
1943 if (points.has_repeat) { | |
1944 CSSFunctionValue* repeat = CSSFunctionValue::Create(CSSValueRepeat); | |
1945 repeat->Append( | |
1946 *ZoomAdjustedPixelValueForLength(points.repeat_offset, style)); | |
1947 return repeat; | |
1948 } | 1967 } |
1949 | |
1950 return CSSIdentifierValue::Create(CSSValueNone); | 1968 return CSSIdentifierValue::Create(CSSValueNone); |
1951 } | 1969 } |
1952 | 1970 |
1953 static CSSValue* ValueForScrollSnapCoordinate( | 1971 static CSSValue* ValueForScrollSnapAlign(const ScrollSnapAlign& align, |
1954 const Vector<LengthPoint>& coordinates, | 1972 const ComputedStyle& style) { |
1955 const ComputedStyle& style) { | 1973 return CSSValuePair::Create(CSSIdentifierValue::Create(align.alignmentX), |
1956 if (coordinates.IsEmpty()) | 1974 CSSIdentifierValue::Create(align.alignmentY), |
1957 return CSSIdentifierValue::Create(CSSValueNone); | 1975 CSSValuePair::kDropIdenticalValues); |
1958 | |
1959 CSSValueList* list = CSSValueList::CreateCommaSeparated(); | |
1960 | |
1961 for (auto& coordinate : coordinates) { | |
1962 auto pair = CSSValueList::CreateSpaceSeparated(); | |
1963 pair->Append(*ZoomAdjustedPixelValueForLength(coordinate.X(), style)); | |
1964 pair->Append(*ZoomAdjustedPixelValueForLength(coordinate.Y(), style)); | |
1965 list->Append(*pair); | |
1966 } | |
1967 | |
1968 return list; | |
1969 } | 1976 } |
1970 | 1977 |
1971 // Returns a suitable value for the page-break-(before|after) property, given | 1978 // Returns a suitable value for the page-break-(before|after) property, given |
1972 // the computed value of the more general break-(before|after) property. | 1979 // the computed value of the more general break-(before|after) property. |
1973 static CSSValue* ValueForPageBreakBetween(EBreakBetween break_value) { | 1980 static CSSValue* ValueForPageBreakBetween(EBreakBetween break_value) { |
1974 switch (break_value) { | 1981 switch (break_value) { |
1975 case EBreakBetween::kAvoidColumn: | 1982 case EBreakBetween::kAvoidColumn: |
1976 case EBreakBetween::kColumn: | 1983 case EBreakBetween::kColumn: |
1977 case EBreakBetween::kRecto: | 1984 case EBreakBetween::kRecto: |
1978 case EBreakBetween::kVerso: | 1985 case EBreakBetween::kVerso: |
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3415 case CSSPropertyMargin: | 3422 case CSSPropertyMargin: |
3416 return ValuesForSidesShorthand(marginShorthand(), style, layout_object, | 3423 return ValuesForSidesShorthand(marginShorthand(), style, layout_object, |
3417 styled_node, allow_visited_style); | 3424 styled_node, allow_visited_style); |
3418 case CSSPropertyOutline: | 3425 case CSSPropertyOutline: |
3419 return ValuesForShorthandProperty(outlineShorthand(), style, | 3426 return ValuesForShorthandProperty(outlineShorthand(), style, |
3420 layout_object, styled_node, | 3427 layout_object, styled_node, |
3421 allow_visited_style); | 3428 allow_visited_style); |
3422 case CSSPropertyPadding: | 3429 case CSSPropertyPadding: |
3423 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object, | 3430 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object, |
3424 styled_node, allow_visited_style); | 3431 styled_node, allow_visited_style); |
3432 case CSSPropertyScrollPadding: | |
3433 return ValuesForSidesShorthand(scrollPaddingShorthand(), style, | |
3434 layout_object, styled_node, | |
3435 allow_visited_style); | |
3436 case CSSPropertyScrollPaddingBlock: | |
3437 return ValuesForInlineBlockShorthand(scrollPaddingBlockShorthand(), style, | |
3438 layout_object, styled_node, | |
3439 allow_visited_style); | |
3440 case CSSPropertyScrollPaddingInline: | |
3441 return ValuesForInlineBlockShorthand(scrollPaddingInlineShorthand(), | |
3442 style, layout_object, styled_node, | |
3443 allow_visited_style); | |
3444 case CSSPropertyScrollSnapMargin: | |
3445 return ValuesForSidesShorthand(scrollSnapMarginShorthand(), style, | |
3446 layout_object, styled_node, | |
3447 allow_visited_style); | |
3448 case CSSPropertyScrollSnapMarginBlock: | |
3449 return ValuesForInlineBlockShorthand(scrollSnapMarginBlockShorthand(), | |
3450 style, layout_object, styled_node, | |
3451 allow_visited_style); | |
3452 case CSSPropertyScrollSnapMarginInline: | |
3453 return ValuesForInlineBlockShorthand(scrollSnapMarginInlineShorthand(), | |
3454 style, layout_object, styled_node, | |
3455 allow_visited_style); | |
3425 // Individual properties not part of the spec. | 3456 // Individual properties not part of the spec. |
3426 case CSSPropertyBackgroundRepeatX: | 3457 case CSSPropertyBackgroundRepeatX: |
3427 case CSSPropertyBackgroundRepeatY: | 3458 case CSSPropertyBackgroundRepeatY: |
3428 return nullptr; | 3459 return nullptr; |
3429 | 3460 |
3430 case CSSPropertyOffset: | 3461 case CSSPropertyOffset: |
3431 return ValuesForShorthandProperty(offsetShorthand(), style, layout_object, | 3462 return ValuesForShorthandProperty(offsetShorthand(), style, layout_object, |
3432 styled_node, allow_visited_style); | 3463 styled_node, allow_visited_style); |
3433 | 3464 |
3434 case CSSPropertyOffsetAnchor: | 3465 case CSSPropertyOffsetAnchor: |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3645 return ZoomAdjustedPixelValueForLength(svg_style.X(), style); | 3676 return ZoomAdjustedPixelValueForLength(svg_style.X(), style); |
3646 case CSSPropertyY: | 3677 case CSSPropertyY: |
3647 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style); | 3678 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style); |
3648 case CSSPropertyR: | 3679 case CSSPropertyR: |
3649 return ZoomAdjustedPixelValueForLength(svg_style.R(), style); | 3680 return ZoomAdjustedPixelValueForLength(svg_style.R(), style); |
3650 case CSSPropertyRx: | 3681 case CSSPropertyRx: |
3651 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style); | 3682 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style); |
3652 case CSSPropertyRy: | 3683 case CSSPropertyRy: |
3653 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style); | 3684 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style); |
3654 case CSSPropertyScrollSnapType: | 3685 case CSSPropertyScrollSnapType: |
3655 return CSSIdentifierValue::Create(style.GetScrollSnapType()); | 3686 return ValueForScrollSnapType(style.GetScrollSnapType(), style); |
3656 case CSSPropertyScrollSnapPointsX: | 3687 case CSSPropertyScrollSnapAlign: |
3657 return ValueForScrollSnapPoints(style.ScrollSnapPointsX(), style); | 3688 return ValueForScrollSnapAlign(style.GetScrollSnapAlign(), style); |
3658 case CSSPropertyScrollSnapPointsY: | 3689 case CSSPropertyScrollSnapStop: |
3659 return ValueForScrollSnapPoints(style.ScrollSnapPointsY(), style); | 3690 return CSSIdentifierValue::Create(style.ScrollSnapStop()); |
3660 case CSSPropertyScrollSnapCoordinate: | 3691 case CSSPropertyScrollPaddingTop: |
3661 return ValueForScrollSnapCoordinate(style.ScrollSnapCoordinate(), style); | 3692 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingTop(), style); |
3662 case CSSPropertyScrollSnapDestination: | 3693 case CSSPropertyScrollPaddingRight: |
3663 return ValueForScrollSnapDestination(style.ScrollSnapDestination(), | 3694 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingRight(), style); |
3664 style); | 3695 case CSSPropertyScrollPaddingBottom: |
3696 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBottom(), | |
3697 style); | |
3698 case CSSPropertyScrollPaddingLeft: | |
3699 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingLeft(), style); | |
3700 case CSSPropertyScrollPaddingBlockStart: | |
3701 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockStart(), | |
3702 style); | |
3703 case CSSPropertyScrollPaddingBlockEnd: | |
3704 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockEnd(), | |
3705 style); | |
3706 case CSSPropertyScrollPaddingInlineStart: | |
3707 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineStart(), | |
3708 style); | |
3709 case CSSPropertyScrollPaddingInlineEnd: | |
3710 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineEnd(), | |
3711 style); | |
3712 case CSSPropertyScrollSnapMarginTop: | |
3713 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginTop(), | |
3714 style); | |
3715 case CSSPropertyScrollSnapMarginRight: | |
3716 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginRight(), | |
3717 style); | |
3718 case CSSPropertyScrollSnapMarginBottom: | |
3719 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBottom(), | |
3720 style); | |
3721 case CSSPropertyScrollSnapMarginLeft: | |
3722 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginLeft(), | |
3723 style); | |
3724 case CSSPropertyScrollSnapMarginBlockStart: | |
3725 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockStart(), | |
3726 style); | |
3727 case CSSPropertyScrollSnapMarginBlockEnd: | |
3728 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockEnd(), | |
3729 style); | |
3730 case CSSPropertyScrollSnapMarginInlineStart: | |
3731 return ZoomAdjustedPixelValueForLength( | |
3732 style.ScrollSnapMarginInlineStart(), style); | |
3733 case CSSPropertyScrollSnapMarginInlineEnd: | |
3734 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginInlineEnd(), | |
3735 style); | |
3665 case CSSPropertyTranslate: { | 3736 case CSSPropertyTranslate: { |
3666 if (!style.Translate()) | 3737 if (!style.Translate()) |
3667 return CSSIdentifierValue::Create(CSSValueNone); | 3738 return CSSIdentifierValue::Create(CSSValueNone); |
3668 | 3739 |
3669 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); | 3740 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); |
3670 if (layout_object && layout_object->IsBox()) { | 3741 if (layout_object && layout_object->IsBox()) { |
3671 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect(); | 3742 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect(); |
3672 list->Append(*ZoomAdjustedPixelValue( | 3743 list->Append(*ZoomAdjustedPixelValue( |
3673 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()), | 3744 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()), |
3674 style)); | 3745 style)); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3754 case CSSPropertyAll: | 3825 case CSSPropertyAll: |
3755 return nullptr; | 3826 return nullptr; |
3756 default: | 3827 default: |
3757 break; | 3828 break; |
3758 } | 3829 } |
3759 NOTREACHED(); | 3830 NOTREACHED(); |
3760 return nullptr; | 3831 return nullptr; |
3761 } | 3832 } |
3762 | 3833 |
3763 } // namespace blink | 3834 } // namespace blink |
OLD | NEW |