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

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

Issue 2368013002: [WIP] CSS Motion Path: offset shorthand ready for position and anchor
Patch Set: code review feedback Created 4 years, 2 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. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (data.positionType() == LegacyPosition) 441 if (data.positionType() == LegacyPosition)
442 result->append(*CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); 442 result->append(*CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
443 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto ' flag to not just mean 'auto' prior to running the StyleAdjuster but also mean 'normal' after running it. 443 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto ' flag to not just mean 'auto' prior to running the StyleAdjuster but also mean 'normal' after running it.
444 result->append(*CSSPrimitiveValue::create(data.position() == ItemPositionAut o ? ComputedStyle::initialDefaultAlignment().position() : data.position())); 444 result->append(*CSSPrimitiveValue::create(data.position() == ItemPositionAut o ? ComputedStyle::initialDefaultAlignment().position() : data.position()));
445 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig nmentDefault) 445 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig nmentDefault)
446 result->append(*CSSPrimitiveValue::create(data.overflow())); 446 result->append(*CSSPrimitiveValue::create(data.overflow()));
447 ASSERT(result->length() <= 2); 447 ASSERT(result->length() <= 2);
448 return result; 448 return result;
449 } 449 }
450 450
451 static CSSValue* valueForOffsetPath(const StylePath* styleMotionPath)
452 {
453 if (styleMotionPath)
454 return styleMotionPath->computedCSSValue();
455 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
456 }
457
458 static CSSValue* valueForOffsetRotation(const StyleOffsetRotation& offsetRotatio n)
459 {
460 CSSValueList* list = CSSValueList::createSpaceSeparated();
461 if (offsetRotation.type == OffsetRotationAuto)
462 list->append(*CSSPrimitiveValue::createIdentifier(CSSValueAuto));
463 list->append(*CSSPrimitiveValue::create(offsetRotation.angle, CSSPrimitiveVa lue::UnitType::Degrees));
464 return list;
465 }
466
451 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN ode, bool allowVisitedStyle) 467 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN ode, bool allowVisitedStyle)
452 { 468 {
453 CSSValueList* list = CSSValueList::createSlashSeparated(); 469 CSSValueList* list = CSSValueList::createSlashSeparated();
454 for (size_t i = 0; i < shorthand.length(); ++i) { 470 for (size_t i = 0; i < shorthand.length(); ++i) {
455 const CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.prop erties()[i], style, layoutObject, styledNode, allowVisitedStyle); 471 const CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.prop erties()[i], style, layoutObject, styledNode, allowVisitedStyle);
456 ASSERT(value); 472 ASSERT(value);
457 list->append(*value); 473 list->append(*value);
458 } 474 }
459 return list; 475 return list;
460 } 476 }
(...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after
1567 list->append(*capsValue); 1583 list->append(*capsValue);
1568 1584
1569 list->append(*valueForFontWeight(style)); 1585 list->append(*valueForFontWeight(style));
1570 list->append(*valueForFontStretch(style)); 1586 list->append(*valueForFontStretch(style));
1571 list->append(*sizeAndLineHeight); 1587 list->append(*sizeAndLineHeight);
1572 list->append(*valueForFontFamily(style)); 1588 list->append(*valueForFontFamily(style));
1573 1589
1574 return list; 1590 return list;
1575 } 1591 }
1576 1592
1593 CSSValue* ComputedStyleCSSValueMapping::valueForOffset(const ComputedStyle& styl e)
1594 {
1595 CSSValueList* list = CSSValueList::createSpaceSeparated();
1596 if (style.offsetPosition() != ComputedStyle::initialOffsetPosition()) {
1597 DCHECK(RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled());
1598 list->append(*valueForPosition(style.offsetPosition(), style));
1599 }
1600
1601 list->append(*valueForOffsetPath(style.offsetPath()));
1602 list->append(*zoomAdjustedPixelValueForLength(style.offsetDistance(), style) );
1603 list->append(*valueForOffsetRotation(style.offsetRotation()));
1604
1605 if (style.offsetAnchor() == ComputedStyle::initialOffsetAnchor())
1606 return list;
1607
1608 DCHECK(RuntimeEnabledFeatures::cssOffsetPositionAnchorEnabled());
1609 CSSValueList* outerList = CSSValueList::createSlashSeparated();
1610 outerList->append(*list);
1611 outerList->append(*valueForPosition(style.offsetAnchor(), style));
1612 return outerList;
1613 }
1614
1577 static CSSValue* valueForScrollSnapDestination(const LengthPoint& destination, c onst ComputedStyle& style) 1615 static CSSValue* valueForScrollSnapDestination(const LengthPoint& destination, c onst ComputedStyle& style)
1578 { 1616 {
1579 CSSValueList* list = CSSValueList::createSpaceSeparated(); 1617 CSSValueList* list = CSSValueList::createSpaceSeparated();
1580 list->append(*zoomAdjustedPixelValueForLength(destination.x(), style)); 1618 list->append(*zoomAdjustedPixelValueForLength(destination.x(), style));
1581 list->append(*zoomAdjustedPixelValueForLength(destination.y(), style)); 1619 list->append(*zoomAdjustedPixelValueForLength(destination.y(), style));
1582 return list; 1620 return list;
1583 } 1621 }
1584 1622
1585 static CSSValue* valueForScrollSnapPoints(const ScrollSnapPoints& points, const ComputedStyle& style) 1623 static CSSValue* valueForScrollSnapPoints(const ScrollSnapPoints& points, const ComputedStyle& style)
1586 { 1624 {
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 return valuesForSidesShorthand(paddingShorthand(), style, layoutObject, styledNode, allowVisitedStyle); 2774 return valuesForSidesShorthand(paddingShorthand(), style, layoutObject, styledNode, allowVisitedStyle);
2737 // Individual properties not part of the spec. 2775 // Individual properties not part of the spec.
2738 case CSSPropertyBackgroundRepeatX: 2776 case CSSPropertyBackgroundRepeatX:
2739 case CSSPropertyBackgroundRepeatY: 2777 case CSSPropertyBackgroundRepeatY:
2740 return nullptr; 2778 return nullptr;
2741 2779
2742 case CSSPropertyMotion: 2780 case CSSPropertyMotion:
2743 return valuesForShorthandProperty(motionShorthand(), style, layoutObject , styledNode, allowVisitedStyle); 2781 return valuesForShorthandProperty(motionShorthand(), style, layoutObject , styledNode, allowVisitedStyle);
2744 2782
2745 case CSSPropertyOffset: 2783 case CSSPropertyOffset:
2746 return valuesForShorthandProperty(offsetShorthand(), style, layoutObject , styledNode, allowVisitedStyle); 2784 return valueForOffset(style);
2747 2785
2748 case CSSPropertyOffsetAnchor: 2786 case CSSPropertyOffsetAnchor:
2749 return valueForPosition(style.offsetAnchor(), style); 2787 return valueForPosition(style.offsetAnchor(), style);
2750 2788
2751 case CSSPropertyOffsetPosition: 2789 case CSSPropertyOffsetPosition:
2752 return valueForPosition(style.offsetPosition(), style); 2790 return valueForPosition(style.offsetPosition(), style);
2753 2791
2754 case CSSPropertyOffsetPath: 2792 case CSSPropertyOffsetPath:
2755 if (const StylePath* styleMotionPath = style.offsetPath()) 2793 return valueForOffsetPath(style.offsetPath());
2756 return styleMotionPath->computedCSSValue();
2757 return CSSPrimitiveValue::createIdentifier(CSSValueNone);
2758 2794
2759 case CSSPropertyOffsetDistance: 2795 case CSSPropertyOffsetDistance:
2760 return zoomAdjustedPixelValueForLength(style.offsetDistance(), style); 2796 return zoomAdjustedPixelValueForLength(style.offsetDistance(), style);
2761 2797
2762 case CSSPropertyOffsetRotation: { 2798 case CSSPropertyOffsetRotation:
2763 CSSValueList* list = CSSValueList::createSpaceSeparated(); 2799 return valueForOffsetRotation(style.offsetRotation());
2764 if (style.offsetRotation().type == OffsetRotationAuto)
2765 list->append(*CSSPrimitiveValue::createIdentifier(CSSValueAuto));
2766 list->append(*CSSPrimitiveValue::create(style.offsetRotation().angle, CS SPrimitiveValue::UnitType::Degrees));
2767 return list;
2768 }
2769 2800
2770 // Unimplemented CSS 3 properties (including CSS3 shorthand properties). 2801 // Unimplemented CSS 3 properties (including CSS3 shorthand properties).
2771 case CSSPropertyWebkitTextEmphasis: 2802 case CSSPropertyWebkitTextEmphasis:
2772 return nullptr; 2803 return nullptr;
2773 2804
2774 // Directional properties are resolved by resolveDirectionAwareProperty() be fore the switch. 2805 // Directional properties are resolved by resolveDirectionAwareProperty() be fore the switch.
2775 case CSSPropertyWebkitBorderEnd: 2806 case CSSPropertyWebkitBorderEnd:
2776 case CSSPropertyWebkitBorderEndColor: 2807 case CSSPropertyWebkitBorderEndColor:
2777 case CSSPropertyWebkitBorderEndStyle: 2808 case CSSPropertyWebkitBorderEndStyle:
2778 case CSSPropertyWebkitBorderEndWidth: 2809 case CSSPropertyWebkitBorderEndWidth:
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
3037 case CSSPropertyAll: 3068 case CSSPropertyAll:
3038 return nullptr; 3069 return nullptr;
3039 default: 3070 default:
3040 break; 3071 break;
3041 } 3072 }
3042 ASSERT_NOT_REACHED(); 3073 ASSERT_NOT_REACHED();
3043 return nullptr; 3074 return nullptr;
3044 } 3075 }
3045 3076
3046 } // namespace blink 3077 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698