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

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

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unskipped some repaint tests and rebaselined. Created 4 years, 7 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 direction = cssValuePool().createIdentifierValue(CSSValueLeft); 420 direction = cssValuePool().createIdentifierValue(CSSValueLeft);
421 break; 421 break;
422 case ReflectionRight: 422 case ReflectionRight:
423 direction = cssValuePool().createIdentifierValue(CSSValueRight); 423 direction = cssValuePool().createIdentifierValue(CSSValueRight);
424 break; 424 break;
425 } 425 }
426 426
427 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref lection->mask(), style)); 427 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref lection->mask(), style));
428 } 428 }
429 429
430 static ItemPosition resolveAlignmentAuto(ItemPosition position, const ComputedSt yle* style) 430 static CSSValueList* valueForItemPositionWithOverflowAlignment(const StyleSelfAl ignmentData& data)
431 {
432 if (position != ItemPositionAuto)
433 return position;
434
435 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
436 return ItemPositionStretch;
437
438 return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart;
439 }
440
441 static CSSValueList* valueForItemPositionWithOverflowAlignment(ItemPosition item Position, OverflowAlignment overflowAlignment, ItemPositionType positionType)
442 { 431 {
443 CSSValueList* result = CSSValueList::createSpaceSeparated(); 432 CSSValueList* result = CSSValueList::createSpaceSeparated();
444 if (positionType == LegacyPosition) 433 if (data.positionType() == LegacyPosition)
445 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); 434 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
446 result->append(CSSPrimitiveValue::create(itemPosition)); 435 // To avoid needing to copy the RareNonInheritedData, we could repurporse th e 'auto' flag to not just mean 'auto' prior to running the StyleAdjuster but als o mean 'normal' after running it.
447 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign mentDefault) 436 result->append(CSSPrimitiveValue::create(data.position() == ItemPositionAuto ? ItemPositionNormal : data.position()));
448 result->append(CSSPrimitiveValue::create(overflowAlignment)); 437 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig nmentDefault)
438 result->append(CSSPrimitiveValue::create(data.overflow()));
449 ASSERT(result->length() <= 2); 439 ASSERT(result->length() <= 2);
450 return result; 440 return result;
451 } 441 }
452 442
453 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN ode, bool allowVisitedStyle) 443 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN ode, bool allowVisitedStyle)
454 { 444 {
455 CSSValueList* list = CSSValueList::createSlashSeparated(); 445 CSSValueList* list = CSSValueList::createSlashSeparated();
456 for (size_t i = 0; i < shorthand.length(); ++i) { 446 for (size_t i = 0; i < shorthand.length(); ++i) {
457 CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.properties ()[i], style, layoutObject, styledNode, allowVisitedStyle); 447 CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.properties ()[i], style, layoutObject, styledNode, allowVisitedStyle);
458 ASSERT(value); 448 ASSERT(value);
(...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 } 1824 }
1835 case CSSPropertyDirection: 1825 case CSSPropertyDirection:
1836 return cssValuePool().createValue(style.direction()); 1826 return cssValuePool().createValue(style.direction());
1837 case CSSPropertyDisplay: 1827 case CSSPropertyDisplay:
1838 return cssValuePool().createValue(style.display()); 1828 return cssValuePool().createValue(style.display());
1839 case CSSPropertyEmptyCells: 1829 case CSSPropertyEmptyCells:
1840 return cssValuePool().createValue(style.emptyCells()); 1830 return cssValuePool().createValue(style.emptyCells());
1841 case CSSPropertyAlignContent: 1831 case CSSPropertyAlignContent:
1842 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent()); 1832 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent());
1843 case CSSPropertyAlignItems: 1833 case CSSPropertyAlignItems:
1844 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac yPosition); 1834 return valueForItemPositionWithOverflowAlignment(style.alignItems());
1845 case CSSPropertyAlignSelf: { 1835 case CSSPropertyAlignSelf:
1846 ItemPosition position = style.alignSelfPosition(); 1836 return valueForItemPositionWithOverflowAlignment(style.alignSelf());
1847 if (position == ItemPositionAuto) {
1848 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par entComputedStyle)
1849 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled Node->parentNode()->ensureComputedStyle() : nullptr;
1850 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart;
1851 }
1852 return valueForItemPositionWithOverflowAlignment(position, style.alignSe lfOverflowAlignment(), NonLegacyPosition);
1853 }
1854 case CSSPropertyFlex: 1837 case CSSPropertyFlex:
1855 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); 1838 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle);
1856 case CSSPropertyFlexBasis: 1839 case CSSPropertyFlexBasis:
1857 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); 1840 return zoomAdjustedPixelValueForLength(style.flexBasis(), style);
1858 case CSSPropertyFlexDirection: 1841 case CSSPropertyFlexDirection:
1859 return cssValuePool().createValue(style.flexDirection()); 1842 return cssValuePool().createValue(style.flexDirection());
1860 case CSSPropertyFlexFlow: 1843 case CSSPropertyFlexFlow:
1861 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); 1844 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle);
1862 case CSSPropertyFlexGrow: 1845 case CSSPropertyFlexGrow:
1863 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); 1846 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1998 return CSSStringValue::create(style.hyphenationString()); 1981 return CSSStringValue::create(style.hyphenationString());
1999 case CSSPropertyImageRendering: 1982 case CSSPropertyImageRendering:
2000 return CSSPrimitiveValue::create(style.imageRendering()); 1983 return CSSPrimitiveValue::create(style.imageRendering());
2001 case CSSPropertyImageOrientation: 1984 case CSSPropertyImageOrientation:
2002 if (style.respectImageOrientation() == RespectImageOrientation) 1985 if (style.respectImageOrientation() == RespectImageOrientation)
2003 return cssValuePool().createIdentifierValue(CSSValueFromImage); 1986 return cssValuePool().createIdentifierValue(CSSValueFromImage);
2004 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s); 1987 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s);
2005 case CSSPropertyIsolation: 1988 case CSSPropertyIsolation:
2006 return cssValuePool().createValue(style.isolation()); 1989 return cssValuePool().createValue(style.isolation());
2007 case CSSPropertyJustifyItems: 1990 case CSSPropertyJustifyItems:
2008 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl e.justifyItemsPositionType()); 1991 return valueForItemPositionWithOverflowAlignment(style.justifyItems());
2009 case CSSPropertyJustifySelf: { 1992 case CSSPropertyJustifySelf:
2010 Node* parent = styledNode->parentNode(); 1993 return valueForItemPositionWithOverflowAlignment(style.justifySelf());
2011 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st yle.justifySelfOverflowAlignment(), NonLegacyPosition);
2012 }
2013 case CSSPropertyLeft: 1994 case CSSPropertyLeft:
2014 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); 1995 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject);
2015 case CSSPropertyLetterSpacing: 1996 case CSSPropertyLetterSpacing:
2016 if (!style.letterSpacing()) 1997 if (!style.letterSpacing())
2017 return cssValuePool().createIdentifierValue(CSSValueNormal); 1998 return cssValuePool().createIdentifierValue(CSSValueNormal);
2018 return zoomAdjustedPixelValue(style.letterSpacing(), style); 1999 return zoomAdjustedPixelValue(style.letterSpacing(), style);
2019 case CSSPropertyWebkitLineClamp: 2000 case CSSPropertyWebkitLineClamp:
2020 if (style.lineClamp().isNone()) 2001 if (style.lineClamp().isNone())
2021 return cssValuePool().createIdentifierValue(CSSValueNone); 2002 return cssValuePool().createIdentifierValue(CSSValueNone);
2022 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number); 2003 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number);
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 case CSSPropertyAll: 2955 case CSSPropertyAll:
2975 return nullptr; 2956 return nullptr;
2976 default: 2957 default:
2977 break; 2958 break;
2978 } 2959 }
2979 ASSERT_NOT_REACHED(); 2960 ASSERT_NOT_REACHED();
2980 return nullptr; 2961 return nullptr;
2981 } 2962 }
2982 2963
2983 } // namespace blink 2964 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698