Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 2932593004: Update the snap points css properties (Closed)
Patch Set: Add CSS Attributes Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
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.
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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 list->Append(*caps_value); 1947 list->Append(*caps_value);
1920 1948
1921 list->Append(*ValueForFontWeight(style)); 1949 list->Append(*ValueForFontWeight(style));
1922 list->Append(*ValueForFontStretch(style)); 1950 list->Append(*ValueForFontStretch(style));
1923 list->Append(*size_and_line_height); 1951 list->Append(*size_and_line_height);
1924 list->Append(*ValueForFontFamily(style)); 1952 list->Append(*ValueForFontFamily(style));
1925 1953
1926 return list; 1954 return list;
1927 } 1955 }
1928 1956
1929 static CSSValue* ValueForScrollSnapDestination(const LengthPoint& destination, 1957 static CSSValue* ValueForScrollSnapType(const ScrollSnapType& type,
1930 const ComputedStyle& style) { 1958 const ComputedStyle& style) {
1931 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 1959 if (type.axis != kSnapAxisNone) {
1932 list->Append(*ZoomAdjustedPixelValueForLength(destination.X(), style)); 1960 return CSSValuePair::Create(CSSIdentifierValue::Create(type.axis),
1933 list->Append(*ZoomAdjustedPixelValueForLength(destination.Y(), style)); 1961 CSSIdentifierValue::Create(type.strictness),
1934 return list; 1962 CSSValuePair::kDropIdenticalValues);
1935 }
1936
1937 static CSSValue* ValueForScrollSnapPoints(const ScrollSnapPoints& points,
1938 const ComputedStyle& style) {
1939 if (points.has_repeat) {
1940 CSSFunctionValue* repeat = CSSFunctionValue::Create(CSSValueRepeat);
1941 repeat->Append(
1942 *ZoomAdjustedPixelValueForLength(points.repeat_offset, style));
1943 return repeat;
1944 } 1963 }
1945
1946 return CSSIdentifierValue::Create(CSSValueNone); 1964 return CSSIdentifierValue::Create(CSSValueNone);
1947 } 1965 }
1948 1966
1949 static CSSValue* ValueForScrollSnapCoordinate( 1967 static CSSValue* ValueForScrollSnapAlign(const ScrollSnapAlign& align,
1950 const Vector<LengthPoint>& coordinates, 1968 const ComputedStyle& style) {
1951 const ComputedStyle& style) { 1969 return CSSValuePair::Create(CSSIdentifierValue::Create(align.alignmentX),
1952 if (coordinates.IsEmpty()) 1970 CSSIdentifierValue::Create(align.alignmentY),
1953 return CSSIdentifierValue::Create(CSSValueNone); 1971 CSSValuePair::kDropIdenticalValues);
1954
1955 CSSValueList* list = CSSValueList::CreateCommaSeparated();
1956
1957 for (auto& coordinate : coordinates) {
1958 auto pair = CSSValueList::CreateSpaceSeparated();
1959 pair->Append(*ZoomAdjustedPixelValueForLength(coordinate.X(), style));
1960 pair->Append(*ZoomAdjustedPixelValueForLength(coordinate.Y(), style));
1961 list->Append(*pair);
1962 }
1963
1964 return list;
1965 } 1972 }
1966 1973
1967 // Returns a suitable value for the page-break-(before|after) property, given 1974 // Returns a suitable value for the page-break-(before|after) property, given
1968 // the computed value of the more general break-(before|after) property. 1975 // the computed value of the more general break-(before|after) property.
1969 static CSSValue* ValueForPageBreakBetween(EBreakBetween break_value) { 1976 static CSSValue* ValueForPageBreakBetween(EBreakBetween break_value) {
1970 switch (break_value) { 1977 switch (break_value) {
1971 case EBreakBetween::kAvoidColumn: 1978 case EBreakBetween::kAvoidColumn:
1972 case EBreakBetween::kColumn: 1979 case EBreakBetween::kColumn:
1973 case EBreakBetween::kRecto: 1980 case EBreakBetween::kRecto:
1974 case EBreakBetween::kVerso: 1981 case EBreakBetween::kVerso:
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3411 case CSSPropertyMargin: 3418 case CSSPropertyMargin:
3412 return ValuesForSidesShorthand(marginShorthand(), style, layout_object, 3419 return ValuesForSidesShorthand(marginShorthand(), style, layout_object,
3413 styled_node, allow_visited_style); 3420 styled_node, allow_visited_style);
3414 case CSSPropertyOutline: 3421 case CSSPropertyOutline:
3415 return ValuesForShorthandProperty(outlineShorthand(), style, 3422 return ValuesForShorthandProperty(outlineShorthand(), style,
3416 layout_object, styled_node, 3423 layout_object, styled_node,
3417 allow_visited_style); 3424 allow_visited_style);
3418 case CSSPropertyPadding: 3425 case CSSPropertyPadding:
3419 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object, 3426 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object,
3420 styled_node, allow_visited_style); 3427 styled_node, allow_visited_style);
3428 case CSSPropertyScrollPadding:
3429 return ValuesForSidesShorthand(scrollPaddingShorthand(), style,
3430 layout_object, styled_node,
3431 allow_visited_style);
3432 case CSSPropertyScrollPaddingBlock:
3433 return ValuesForInlineBlockShorthand(scrollPaddingBlockShorthand(), style,
3434 layout_object, styled_node,
3435 allow_visited_style);
3436 case CSSPropertyScrollPaddingInline:
3437 return ValuesForInlineBlockShorthand(scrollPaddingInlineShorthand(),
3438 style, layout_object, styled_node,
3439 allow_visited_style);
3440 case CSSPropertyScrollSnapMargin:
3441 return ValuesForSidesShorthand(scrollSnapMarginShorthand(), style,
3442 layout_object, styled_node,
3443 allow_visited_style);
3444 case CSSPropertyScrollSnapMarginBlock:
3445 return ValuesForInlineBlockShorthand(scrollSnapMarginBlockShorthand(),
3446 style, layout_object, styled_node,
3447 allow_visited_style);
3448 case CSSPropertyScrollSnapMarginInline:
3449 return ValuesForInlineBlockShorthand(scrollSnapMarginInlineShorthand(),
3450 style, layout_object, styled_node,
3451 allow_visited_style);
3421 // Individual properties not part of the spec. 3452 // Individual properties not part of the spec.
3422 case CSSPropertyBackgroundRepeatX: 3453 case CSSPropertyBackgroundRepeatX:
3423 case CSSPropertyBackgroundRepeatY: 3454 case CSSPropertyBackgroundRepeatY:
3424 return nullptr; 3455 return nullptr;
3425 3456
3426 case CSSPropertyOffset: 3457 case CSSPropertyOffset:
3427 return ValuesForShorthandProperty(offsetShorthand(), style, layout_object, 3458 return ValuesForShorthandProperty(offsetShorthand(), style, layout_object,
3428 styled_node, allow_visited_style); 3459 styled_node, allow_visited_style);
3429 3460
3430 case CSSPropertyOffsetAnchor: 3461 case CSSPropertyOffsetAnchor:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3641 return ZoomAdjustedPixelValueForLength(svg_style.X(), style); 3672 return ZoomAdjustedPixelValueForLength(svg_style.X(), style);
3642 case CSSPropertyY: 3673 case CSSPropertyY:
3643 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style); 3674 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style);
3644 case CSSPropertyR: 3675 case CSSPropertyR:
3645 return ZoomAdjustedPixelValueForLength(svg_style.R(), style); 3676 return ZoomAdjustedPixelValueForLength(svg_style.R(), style);
3646 case CSSPropertyRx: 3677 case CSSPropertyRx:
3647 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style); 3678 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style);
3648 case CSSPropertyRy: 3679 case CSSPropertyRy:
3649 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style); 3680 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style);
3650 case CSSPropertyScrollSnapType: 3681 case CSSPropertyScrollSnapType:
3651 return CSSIdentifierValue::Create(style.GetScrollSnapType()); 3682 return ValueForScrollSnapType(style.GetScrollSnapType(), style);
3652 case CSSPropertyScrollSnapPointsX: 3683 case CSSPropertyScrollSnapAlign:
3653 return ValueForScrollSnapPoints(style.ScrollSnapPointsX(), style); 3684 return ValueForScrollSnapAlign(style.GetScrollSnapAlign(), style);
3654 case CSSPropertyScrollSnapPointsY: 3685 case CSSPropertyScrollSnapStop:
3655 return ValueForScrollSnapPoints(style.ScrollSnapPointsY(), style); 3686 return CSSIdentifierValue::Create(style.ScrollSnapStop());
3656 case CSSPropertyScrollSnapCoordinate: 3687 case CSSPropertyScrollPaddingTop:
3657 return ValueForScrollSnapCoordinate(style.ScrollSnapCoordinate(), style); 3688 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingTop(), style);
3658 case CSSPropertyScrollSnapDestination: 3689 case CSSPropertyScrollPaddingRight:
3659 return ValueForScrollSnapDestination(style.ScrollSnapDestination(), 3690 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingRight(), style);
3660 style); 3691 case CSSPropertyScrollPaddingBottom:
3692 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBottom(),
3693 style);
3694 case CSSPropertyScrollPaddingLeft:
3695 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingLeft(), style);
3696 case CSSPropertyScrollPaddingBlockStart:
3697 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockStart(),
3698 style);
3699 case CSSPropertyScrollPaddingBlockEnd:
3700 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockEnd(),
3701 style);
3702 case CSSPropertyScrollPaddingInlineStart:
3703 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineStart(),
3704 style);
3705 case CSSPropertyScrollPaddingInlineEnd:
3706 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineEnd(),
3707 style);
3708 case CSSPropertyScrollSnapMarginTop:
3709 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginTop(),
3710 style);
3711 case CSSPropertyScrollSnapMarginRight:
3712 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginRight(),
3713 style);
3714 case CSSPropertyScrollSnapMarginBottom:
3715 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBottom(),
3716 style);
3717 case CSSPropertyScrollSnapMarginLeft:
3718 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginLeft(),
3719 style);
3720 case CSSPropertyScrollSnapMarginBlockStart:
3721 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockStart(),
3722 style);
3723 case CSSPropertyScrollSnapMarginBlockEnd:
3724 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockEnd(),
3725 style);
3726 case CSSPropertyScrollSnapMarginInlineStart:
3727 return ZoomAdjustedPixelValueForLength(
3728 style.ScrollSnapMarginInlineStart(), style);
3729 case CSSPropertyScrollSnapMarginInlineEnd:
3730 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginInlineEnd(),
3731 style);
3661 case CSSPropertyTranslate: { 3732 case CSSPropertyTranslate: {
3662 if (!style.Translate()) 3733 if (!style.Translate())
3663 return CSSIdentifierValue::Create(CSSValueNone); 3734 return CSSIdentifierValue::Create(CSSValueNone);
3664 3735
3665 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 3736 CSSValueList* list = CSSValueList::CreateSpaceSeparated();
3666 if (layout_object && layout_object->IsBox()) { 3737 if (layout_object && layout_object->IsBox()) {
3667 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect(); 3738 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect();
3668 list->Append(*ZoomAdjustedPixelValue( 3739 list->Append(*ZoomAdjustedPixelValue(
3669 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()), 3740 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()),
3670 style)); 3741 style));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3750 case CSSPropertyAll: 3821 case CSSPropertyAll:
3751 return nullptr; 3822 return nullptr;
3752 default: 3823 default:
3753 break; 3824 break;
3754 } 3825 }
3755 NOTREACHED(); 3826 NOTREACHED();
3756 return nullptr; 3827 return nullptr;
3757 } 3828 }
3758 3829
3759 } // namespace blink 3830 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698