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

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

Issue 2932593004: Update the snap points css properties (Closed)
Patch Set: Fix nits 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 CSSValuePair* ValuesForInlineBlockShorthand(
1657 const StylePropertyShorthand& shorthand,
1658 const ComputedStyle& style,
1659 const LayoutObject* layout_object,
1660 Node* styled_node,
1661 bool allow_visited_style) {
1662 const CSSValue* start_value = ComputedStyleCSSValueMapping::Get(
1663 shorthand.properties()[0], style, layout_object, styled_node,
1664 allow_visited_style);
1665 const CSSValue* end_value = ComputedStyleCSSValueMapping::Get(
1666 shorthand.properties()[1], style, layout_object, styled_node,
1667 allow_visited_style);
1668 // Both properties must be specified.
1669 if (!start_value || !end_value)
1670 return nullptr;
1671
1672 CSSValuePair* pair = CSSValuePair::Create(start_value, end_value,
1673 CSSValuePair::kDropIdenticalValues);
1674 return pair;
1675 }
1676
1656 static CSSValueList* ValueForBorderRadiusShorthand(const ComputedStyle& style) { 1677 static CSSValueList* ValueForBorderRadiusShorthand(const ComputedStyle& style) {
1657 CSSValueList* list = CSSValueList::CreateSlashSeparated(); 1678 CSSValueList* list = CSSValueList::CreateSlashSeparated();
1658 1679
1659 bool show_horizontal_bottom_left = style.BorderTopRightRadius().Width() != 1680 bool show_horizontal_bottom_left = style.BorderTopRightRadius().Width() !=
1660 style.BorderBottomLeftRadius().Width(); 1681 style.BorderBottomLeftRadius().Width();
1661 bool show_horizontal_bottom_right = 1682 bool show_horizontal_bottom_right =
1662 show_horizontal_bottom_left || (style.BorderBottomRightRadius().Width() != 1683 show_horizontal_bottom_left || (style.BorderBottomRightRadius().Width() !=
1663 style.BorderTopLeftRadius().Width()); 1684 style.BorderTopLeftRadius().Width());
1664 bool show_horizontal_top_right = 1685 bool show_horizontal_top_right =
1665 show_horizontal_bottom_right || (style.BorderTopRightRadius().Width() != 1686 show_horizontal_bottom_right || (style.BorderTopRightRadius().Width() !=
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 list->Append(*caps_value); 1982 list->Append(*caps_value);
1962 1983
1963 list->Append(*ValueForFontWeight(style)); 1984 list->Append(*ValueForFontWeight(style));
1964 list->Append(*ValueForFontStretch(style)); 1985 list->Append(*ValueForFontStretch(style));
1965 list->Append(*size_and_line_height); 1986 list->Append(*size_and_line_height);
1966 list->Append(*ValueForFontFamily(style)); 1987 list->Append(*ValueForFontFamily(style));
1967 1988
1968 return list; 1989 return list;
1969 } 1990 }
1970 1991
1971 static CSSValue* ValueForScrollSnapDestination(const LengthPoint& destination, 1992 static CSSValue* ValueForScrollSnapType(const ScrollSnapType& type,
1972 const ComputedStyle& style) { 1993 const ComputedStyle& style) {
1973 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 1994 if (!type.is_none) {
1974 list->Append(*ZoomAdjustedPixelValueForLength(destination.X(), style)); 1995 return CSSValuePair::Create(CSSIdentifierValue::Create(type.axis),
1975 list->Append(*ZoomAdjustedPixelValueForLength(destination.Y(), style)); 1996 CSSIdentifierValue::Create(type.strictness),
1976 return list; 1997 CSSValuePair::kDropIdenticalValues);
1977 }
1978
1979 static CSSValue* ValueForScrollSnapPoints(const ScrollSnapPoints& points,
1980 const ComputedStyle& style) {
1981 if (points.has_repeat) {
1982 CSSFunctionValue* repeat = CSSFunctionValue::Create(CSSValueRepeat);
1983 repeat->Append(
1984 *ZoomAdjustedPixelValueForLength(points.repeat_offset, style));
1985 return repeat;
1986 } 1998 }
1987
1988 return CSSIdentifierValue::Create(CSSValueNone); 1999 return CSSIdentifierValue::Create(CSSValueNone);
1989 } 2000 }
1990 2001
1991 static CSSValue* ValueForScrollSnapCoordinate( 2002 static CSSValue* ValueForScrollSnapAlign(const ScrollSnapAlign& align,
1992 const Vector<LengthPoint>& coordinates, 2003 const ComputedStyle& style) {
1993 const ComputedStyle& style) { 2004 return CSSValuePair::Create(CSSIdentifierValue::Create(align.alignmentX),
1994 if (coordinates.IsEmpty()) 2005 CSSIdentifierValue::Create(align.alignmentY),
1995 return CSSIdentifierValue::Create(CSSValueNone); 2006 CSSValuePair::kDropIdenticalValues);
1996
1997 CSSValueList* list = CSSValueList::CreateCommaSeparated();
1998
1999 for (auto& coordinate : coordinates) {
2000 auto pair = CSSValueList::CreateSpaceSeparated();
2001 pair->Append(*ZoomAdjustedPixelValueForLength(coordinate.X(), style));
2002 pair->Append(*ZoomAdjustedPixelValueForLength(coordinate.Y(), style));
2003 list->Append(*pair);
2004 }
2005
2006 return list;
2007 } 2007 }
2008 2008
2009 // Returns a suitable value for the page-break-(before|after) property, given 2009 // Returns a suitable value for the page-break-(before|after) property, given
2010 // the computed value of the more general break-(before|after) property. 2010 // the computed value of the more general break-(before|after) property.
2011 static CSSValue* ValueForPageBreakBetween(EBreakBetween break_value) { 2011 static CSSValue* ValueForPageBreakBetween(EBreakBetween break_value) {
2012 switch (break_value) { 2012 switch (break_value) {
2013 case EBreakBetween::kAvoidColumn: 2013 case EBreakBetween::kAvoidColumn:
2014 case EBreakBetween::kColumn: 2014 case EBreakBetween::kColumn:
2015 case EBreakBetween::kRecto: 2015 case EBreakBetween::kRecto:
2016 case EBreakBetween::kVerso: 2016 case EBreakBetween::kVerso:
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 case CSSPropertyMargin: 3453 case CSSPropertyMargin:
3454 return ValuesForSidesShorthand(marginShorthand(), style, layout_object, 3454 return ValuesForSidesShorthand(marginShorthand(), style, layout_object,
3455 styled_node, allow_visited_style); 3455 styled_node, allow_visited_style);
3456 case CSSPropertyOutline: 3456 case CSSPropertyOutline:
3457 return ValuesForShorthandProperty(outlineShorthand(), style, 3457 return ValuesForShorthandProperty(outlineShorthand(), style,
3458 layout_object, styled_node, 3458 layout_object, styled_node,
3459 allow_visited_style); 3459 allow_visited_style);
3460 case CSSPropertyPadding: 3460 case CSSPropertyPadding:
3461 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object, 3461 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object,
3462 styled_node, allow_visited_style); 3462 styled_node, allow_visited_style);
3463 case CSSPropertyScrollPadding:
3464 return ValuesForSidesShorthand(scrollPaddingShorthand(), style,
3465 layout_object, styled_node,
3466 allow_visited_style);
3467 case CSSPropertyScrollPaddingBlock:
3468 return ValuesForInlineBlockShorthand(scrollPaddingBlockShorthand(), style,
3469 layout_object, styled_node,
3470 allow_visited_style);
3471 case CSSPropertyScrollPaddingInline:
3472 return ValuesForInlineBlockShorthand(scrollPaddingInlineShorthand(),
3473 style, layout_object, styled_node,
3474 allow_visited_style);
3475 case CSSPropertyScrollSnapMargin:
3476 return ValuesForSidesShorthand(scrollSnapMarginShorthand(), style,
3477 layout_object, styled_node,
3478 allow_visited_style);
3479 case CSSPropertyScrollSnapMarginBlock:
3480 return ValuesForInlineBlockShorthand(scrollSnapMarginBlockShorthand(),
3481 style, layout_object, styled_node,
3482 allow_visited_style);
3483 case CSSPropertyScrollSnapMarginInline:
3484 return ValuesForInlineBlockShorthand(scrollSnapMarginInlineShorthand(),
3485 style, layout_object, styled_node,
3486 allow_visited_style);
3463 // Individual properties not part of the spec. 3487 // Individual properties not part of the spec.
3464 case CSSPropertyBackgroundRepeatX: 3488 case CSSPropertyBackgroundRepeatX:
3465 case CSSPropertyBackgroundRepeatY: 3489 case CSSPropertyBackgroundRepeatY:
3466 return nullptr; 3490 return nullptr;
3467 3491
3468 case CSSPropertyOffset: 3492 case CSSPropertyOffset:
3469 return ValueForOffset(style, layout_object, styled_node, 3493 return ValueForOffset(style, layout_object, styled_node,
3470 allow_visited_style); 3494 allow_visited_style);
3471 3495
3472 case CSSPropertyOffsetAnchor: 3496 case CSSPropertyOffsetAnchor:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3683 return ZoomAdjustedPixelValueForLength(svg_style.X(), style); 3707 return ZoomAdjustedPixelValueForLength(svg_style.X(), style);
3684 case CSSPropertyY: 3708 case CSSPropertyY:
3685 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style); 3709 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style);
3686 case CSSPropertyR: 3710 case CSSPropertyR:
3687 return ZoomAdjustedPixelValueForLength(svg_style.R(), style); 3711 return ZoomAdjustedPixelValueForLength(svg_style.R(), style);
3688 case CSSPropertyRx: 3712 case CSSPropertyRx:
3689 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style); 3713 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style);
3690 case CSSPropertyRy: 3714 case CSSPropertyRy:
3691 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style); 3715 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style);
3692 case CSSPropertyScrollSnapType: 3716 case CSSPropertyScrollSnapType:
3693 return CSSIdentifierValue::Create(style.GetScrollSnapType()); 3717 return ValueForScrollSnapType(style.GetScrollSnapType(), style);
3694 case CSSPropertyScrollSnapPointsX: 3718 case CSSPropertyScrollSnapAlign:
3695 return ValueForScrollSnapPoints(style.ScrollSnapPointsX(), style); 3719 return ValueForScrollSnapAlign(style.GetScrollSnapAlign(), style);
3696 case CSSPropertyScrollSnapPointsY: 3720 case CSSPropertyScrollSnapStop:
3697 return ValueForScrollSnapPoints(style.ScrollSnapPointsY(), style); 3721 return CSSIdentifierValue::Create(style.ScrollSnapStop());
3698 case CSSPropertyScrollSnapCoordinate: 3722 case CSSPropertyScrollPaddingTop:
3699 return ValueForScrollSnapCoordinate(style.ScrollSnapCoordinate(), style); 3723 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingTop(), style);
3700 case CSSPropertyScrollSnapDestination: 3724 case CSSPropertyScrollPaddingRight:
3701 return ValueForScrollSnapDestination(style.ScrollSnapDestination(), 3725 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingRight(), style);
3702 style); 3726 case CSSPropertyScrollPaddingBottom:
3727 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBottom(),
3728 style);
3729 case CSSPropertyScrollPaddingLeft:
3730 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingLeft(), style);
3731 case CSSPropertyScrollPaddingBlockStart:
3732 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockStart(),
3733 style);
3734 case CSSPropertyScrollPaddingBlockEnd:
3735 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockEnd(),
3736 style);
3737 case CSSPropertyScrollPaddingInlineStart:
3738 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineStart(),
3739 style);
3740 case CSSPropertyScrollPaddingInlineEnd:
3741 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineEnd(),
3742 style);
3743 case CSSPropertyScrollSnapMarginTop:
3744 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginTop(),
3745 style);
3746 case CSSPropertyScrollSnapMarginRight:
3747 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginRight(),
3748 style);
3749 case CSSPropertyScrollSnapMarginBottom:
3750 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBottom(),
3751 style);
3752 case CSSPropertyScrollSnapMarginLeft:
3753 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginLeft(),
3754 style);
3755 case CSSPropertyScrollSnapMarginBlockStart:
3756 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockStart(),
3757 style);
3758 case CSSPropertyScrollSnapMarginBlockEnd:
3759 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockEnd(),
3760 style);
3761 case CSSPropertyScrollSnapMarginInlineStart:
3762 return ZoomAdjustedPixelValueForLength(
3763 style.ScrollSnapMarginInlineStart(), style);
3764 case CSSPropertyScrollSnapMarginInlineEnd:
3765 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginInlineEnd(),
3766 style);
3703 case CSSPropertyTranslate: { 3767 case CSSPropertyTranslate: {
3704 if (!style.Translate()) 3768 if (!style.Translate())
3705 return CSSIdentifierValue::Create(CSSValueNone); 3769 return CSSIdentifierValue::Create(CSSValueNone);
3706 3770
3707 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 3771 CSSValueList* list = CSSValueList::CreateSpaceSeparated();
3708 if (layout_object && layout_object->IsBox()) { 3772 if (layout_object && layout_object->IsBox()) {
3709 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect(); 3773 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect();
3710 list->Append(*ZoomAdjustedPixelValue( 3774 list->Append(*ZoomAdjustedPixelValue(
3711 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()), 3775 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()),
3712 style)); 3776 style));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3792 case CSSPropertyAll: 3856 case CSSPropertyAll:
3793 return nullptr; 3857 return nullptr;
3794 default: 3858 default:
3795 break; 3859 break;
3796 } 3860 }
3797 NOTREACHED(); 3861 NOTREACHED();
3798 return nullptr; 3862 return nullptr;
3799 } 3863 }
3800 3864
3801 } // namespace blink 3865 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698