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

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

Issue 2767213003: First Implementation of Snapped Points
Patch Set: Rebase and format 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 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 list->Append(*caps_value); 1919 list->Append(*caps_value);
1920 1920
1921 list->Append(*ValueForFontWeight(style)); 1921 list->Append(*ValueForFontWeight(style));
1922 list->Append(*ValueForFontStretch(style)); 1922 list->Append(*ValueForFontStretch(style));
1923 list->Append(*size_and_line_height); 1923 list->Append(*size_and_line_height);
1924 list->Append(*ValueForFontFamily(style)); 1924 list->Append(*ValueForFontFamily(style));
1925 1925
1926 return list; 1926 return list;
1927 } 1927 }
1928 1928
1929 static CSSValue* ValueForScrollSnapType(const ScrollSnapType& type,
1930 const ComputedStyle& style) {
1931 if (type.axis != kSnapAxisNone) {
1932 return CSSValuePair::Create(CSSIdentifierValue::Create(type.axis),
1933 CSSIdentifierValue::Create(type.strictness),
1934 CSSValuePair::kDropIdenticalValues);
1935 }
1936 return CSSIdentifierValue::Create(CSSValueNone);
1937 }
1938
1939 static CSSValue* ValueForScrollSnapAlign(const ScrollSnapAlign& align,
1940 const ComputedStyle& style) {
1941 return CSSValuePair::Create(CSSIdentifierValue::Create(align.alignmentX),
1942 CSSIdentifierValue::Create(align.alignmentY),
1943 CSSValuePair::kDropIdenticalValues);
1944 }
1945
1929 static CSSValue* ValueForScrollSnapDestination(const LengthPoint& destination, 1946 static CSSValue* ValueForScrollSnapDestination(const LengthPoint& destination,
1930 const ComputedStyle& style) { 1947 const ComputedStyle& style) {
1931 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 1948 CSSValueList* list = CSSValueList::CreateSpaceSeparated();
1932 list->Append(*ZoomAdjustedPixelValueForLength(destination.X(), style)); 1949 list->Append(*ZoomAdjustedPixelValueForLength(destination.X(), style));
1933 list->Append(*ZoomAdjustedPixelValueForLength(destination.Y(), style)); 1950 list->Append(*ZoomAdjustedPixelValueForLength(destination.Y(), style));
1934 return list; 1951 return list;
1935 } 1952 }
1936 1953
1937 static CSSValue* ValueForScrollSnapPoints(const ScrollSnapPoints& points, 1954 static CSSValue* ValueForScrollSnapPoints(const ScrollSnapPoints& points,
1938 const ComputedStyle& style) { 1955 const ComputedStyle& style) {
(...skipping 1472 matching lines...) Expand 10 before | Expand all | Expand 10 after
3411 case CSSPropertyMargin: 3428 case CSSPropertyMargin:
3412 return ValuesForSidesShorthand(marginShorthand(), style, layout_object, 3429 return ValuesForSidesShorthand(marginShorthand(), style, layout_object,
3413 styled_node, allow_visited_style); 3430 styled_node, allow_visited_style);
3414 case CSSPropertyOutline: 3431 case CSSPropertyOutline:
3415 return ValuesForShorthandProperty(outlineShorthand(), style, 3432 return ValuesForShorthandProperty(outlineShorthand(), style,
3416 layout_object, styled_node, 3433 layout_object, styled_node,
3417 allow_visited_style); 3434 allow_visited_style);
3418 case CSSPropertyPadding: 3435 case CSSPropertyPadding:
3419 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object, 3436 return ValuesForSidesShorthand(paddingShorthand(), style, layout_object,
3420 styled_node, allow_visited_style); 3437 styled_node, allow_visited_style);
3438 case CSSPropertyScrollPadding:
3439 return ValuesForSidesShorthand(scrollPaddingShorthand(), style,
3440 layout_object, styled_node,
3441 allow_visited_style);
3442 case CSSPropertyScrollPaddingBlock:
3443 return ValuesForShorthandProperty(scrollPaddingBlockShorthand(), style,
3444 layout_object, styled_node,
3445 allow_visited_style);
3446 case CSSPropertyScrollPaddingInline:
3447 return ValuesForShorthandProperty(scrollPaddingInlineShorthand(), style,
3448 layout_object, styled_node,
3449 allow_visited_style);
3450 case CSSPropertyScrollSnapMargin:
3451 return ValuesForSidesShorthand(scrollSnapMarginShorthand(), style,
3452 layout_object, styled_node,
3453 allow_visited_style);
3454 case CSSPropertyScrollSnapMarginBlock:
3455 return ValuesForShorthandProperty(scrollSnapMarginBlockShorthand(), style,
3456 layout_object, styled_node,
3457 allow_visited_style);
3458 case CSSPropertyScrollSnapMarginInline:
3459 return ValuesForShorthandProperty(scrollSnapMarginInlineShorthand(),
3460 style, layout_object, styled_node,
3461 allow_visited_style);
3421 // Individual properties not part of the spec. 3462 // Individual properties not part of the spec.
3422 case CSSPropertyBackgroundRepeatX: 3463 case CSSPropertyBackgroundRepeatX:
3423 case CSSPropertyBackgroundRepeatY: 3464 case CSSPropertyBackgroundRepeatY:
3424 return nullptr; 3465 return nullptr;
3425 3466
3426 case CSSPropertyOffset: 3467 case CSSPropertyOffset:
3427 return ValuesForShorthandProperty(offsetShorthand(), style, layout_object, 3468 return ValuesForShorthandProperty(offsetShorthand(), style, layout_object,
3428 styled_node, allow_visited_style); 3469 styled_node, allow_visited_style);
3429 3470
3430 case CSSPropertyOffsetAnchor: 3471 case CSSPropertyOffsetAnchor:
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3641 return ZoomAdjustedPixelValueForLength(svg_style.X(), style); 3682 return ZoomAdjustedPixelValueForLength(svg_style.X(), style);
3642 case CSSPropertyY: 3683 case CSSPropertyY:
3643 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style); 3684 return ZoomAdjustedPixelValueForLength(svg_style.Y(), style);
3644 case CSSPropertyR: 3685 case CSSPropertyR:
3645 return ZoomAdjustedPixelValueForLength(svg_style.R(), style); 3686 return ZoomAdjustedPixelValueForLength(svg_style.R(), style);
3646 case CSSPropertyRx: 3687 case CSSPropertyRx:
3647 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style); 3688 return ZoomAdjustedPixelValueForLength(svg_style.Rx(), style);
3648 case CSSPropertyRy: 3689 case CSSPropertyRy:
3649 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style); 3690 return ZoomAdjustedPixelValueForLength(svg_style.Ry(), style);
3650 case CSSPropertyScrollSnapType: 3691 case CSSPropertyScrollSnapType:
3651 return CSSIdentifierValue::Create(style.GetScrollSnapType()); 3692 return ValueForScrollSnapType(style.GetScrollSnapType(), style);
3652 case CSSPropertyScrollSnapPointsX: 3693 case CSSPropertyScrollSnapPointsX:
3653 return ValueForScrollSnapPoints(style.ScrollSnapPointsX(), style); 3694 return ValueForScrollSnapPoints(style.ScrollSnapPointsX(), style);
3654 case CSSPropertyScrollSnapPointsY: 3695 case CSSPropertyScrollSnapPointsY:
3655 return ValueForScrollSnapPoints(style.ScrollSnapPointsY(), style); 3696 return ValueForScrollSnapPoints(style.ScrollSnapPointsY(), style);
3656 case CSSPropertyScrollSnapCoordinate: 3697 case CSSPropertyScrollSnapCoordinate:
3657 return ValueForScrollSnapCoordinate(style.ScrollSnapCoordinate(), style); 3698 return ValueForScrollSnapCoordinate(style.ScrollSnapCoordinate(), style);
3658 case CSSPropertyScrollSnapDestination: 3699 case CSSPropertyScrollSnapDestination:
3659 return ValueForScrollSnapDestination(style.ScrollSnapDestination(), 3700 return ValueForScrollSnapDestination(style.ScrollSnapDestination(),
3660 style); 3701 style);
3702 case CSSPropertyScrollSnapAlign:
3703 return ValueForScrollSnapAlign(style.GetScrollSnapAlign(), style);
3704 case CSSPropertyScrollSnapStop:
3705 return CSSIdentifierValue::Create(style.ScrollSnapStop());
3706 case CSSPropertyScrollPaddingTop:
3707 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingTop(), style);
3708 case CSSPropertyScrollPaddingRight:
3709 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingRight(), style);
3710 case CSSPropertyScrollPaddingBottom:
3711 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBottom(),
3712 style);
3713 case CSSPropertyScrollPaddingLeft:
3714 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingLeft(), style);
3715 case CSSPropertyScrollPaddingBlockStart:
3716 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockStart(),
3717 style);
3718 case CSSPropertyScrollPaddingBlockEnd:
3719 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingBlockEnd(),
3720 style);
3721 case CSSPropertyScrollPaddingInlineStart:
3722 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineStart(),
3723 style);
3724 case CSSPropertyScrollPaddingInlineEnd:
3725 return ZoomAdjustedPixelValueForLength(style.ScrollPaddingInlineEnd(),
3726 style);
3727 case CSSPropertyScrollSnapMarginTop:
3728 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginTop(),
3729 style);
3730 case CSSPropertyScrollSnapMarginRight:
3731 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginRight(),
3732 style);
3733 case CSSPropertyScrollSnapMarginBottom:
3734 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBottom(),
3735 style);
3736 case CSSPropertyScrollSnapMarginLeft:
3737 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginLeft(),
3738 style);
3739 case CSSPropertyScrollSnapMarginBlockStart:
3740 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockStart(),
3741 style);
3742 case CSSPropertyScrollSnapMarginBlockEnd:
3743 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginBlockEnd(),
3744 style);
3745 case CSSPropertyScrollSnapMarginInlineStart:
3746 return ZoomAdjustedPixelValueForLength(
3747 style.ScrollSnapMarginInlineStart(), style);
3748 case CSSPropertyScrollSnapMarginInlineEnd:
3749 return ZoomAdjustedPixelValueForLength(style.ScrollSnapMarginInlineEnd(),
3750 style);
3661 case CSSPropertyTranslate: { 3751 case CSSPropertyTranslate: {
3662 if (!style.Translate()) 3752 if (!style.Translate())
3663 return CSSIdentifierValue::Create(CSSValueNone); 3753 return CSSIdentifierValue::Create(CSSValueNone);
3664 3754
3665 CSSValueList* list = CSSValueList::CreateSpaceSeparated(); 3755 CSSValueList* list = CSSValueList::CreateSpaceSeparated();
3666 if (layout_object && layout_object->IsBox()) { 3756 if (layout_object && layout_object->IsBox()) {
3667 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect(); 3757 LayoutRect box = ToLayoutBox(layout_object)->BorderBoxRect();
3668 list->Append(*ZoomAdjustedPixelValue( 3758 list->Append(*ZoomAdjustedPixelValue(
3669 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()), 3759 FloatValueForLength(style.Translate()->X(), box.Width().ToFloat()),
3670 style)); 3760 style));
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3750 case CSSPropertyAll: 3840 case CSSPropertyAll:
3751 return nullptr; 3841 return nullptr;
3752 default: 3842 default:
3753 break; 3843 break;
3754 } 3844 }
3755 NOTREACHED(); 3845 NOTREACHED();
3756 return nullptr; 3846 return nullptr;
3757 } 3847 }
3758 3848
3759 } // namespace blink 3849 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698