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

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: Fixed repaint tests. Created 4 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. 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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 direction = cssValuePool().createIdentifierValue(CSSValueLeft); 428 direction = cssValuePool().createIdentifierValue(CSSValueLeft);
429 break; 429 break;
430 case ReflectionRight: 430 case ReflectionRight:
431 direction = cssValuePool().createIdentifierValue(CSSValueRight); 431 direction = cssValuePool().createIdentifierValue(CSSValueRight);
432 break; 432 break;
433 } 433 }
434 434
435 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref lection->mask(), style)); 435 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref lection->mask(), style));
436 } 436 }
437 437
438 static ItemPosition resolveAlignmentAuto(ItemPosition position, const ComputedSt yle* style) 438 static CSSValueList* valueForItemPositionWithOverflowAlignment(const StyleSelfAl ignmentData& data)
439 {
440 if (position != ItemPositionAuto)
441 return position;
442
443 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
444 return ItemPositionStretch;
445
446 return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart;
447 }
448
449 static CSSValueList* valueForItemPositionWithOverflowAlignment(ItemPosition item Position, OverflowAlignment overflowAlignment, ItemPositionType positionType)
450 { 439 {
451 CSSValueList* result = CSSValueList::createSpaceSeparated(); 440 CSSValueList* result = CSSValueList::createSpaceSeparated();
452 if (positionType == LegacyPosition) 441 if (data.positionType() == LegacyPosition)
453 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); 442 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));
454 result->append(CSSPrimitiveValue::create(itemPosition)); 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.
455 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign mentDefault) 444 result->append(CSSPrimitiveValue::create(data.position() == ItemPositionAuto ? ItemPositionNormal : data.position()));
456 result->append(CSSPrimitiveValue::create(overflowAlignment)); 445 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig nmentDefault)
446 result->append(CSSPrimitiveValue::create(data.overflow()));
457 ASSERT(result->length() <= 2); 447 ASSERT(result->length() <= 2);
458 return result; 448 return result;
459 } 449 }
460 450
461 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN ode, bool allowVisitedStyle) 451 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN ode, bool allowVisitedStyle)
462 { 452 {
463 CSSValueList* list = CSSValueList::createSlashSeparated(); 453 CSSValueList* list = CSSValueList::createSlashSeparated();
464 for (size_t i = 0; i < shorthand.length(); ++i) { 454 for (size_t i = 0; i < shorthand.length(); ++i) {
465 CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.properties ()[i], style, layoutObject, styledNode, allowVisitedStyle); 455 CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.properties ()[i], style, layoutObject, styledNode, allowVisitedStyle);
466 ASSERT(value); 456 ASSERT(value);
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 } 1856 }
1867 case CSSPropertyDirection: 1857 case CSSPropertyDirection:
1868 return cssValuePool().createValue(style.direction()); 1858 return cssValuePool().createValue(style.direction());
1869 case CSSPropertyDisplay: 1859 case CSSPropertyDisplay:
1870 return cssValuePool().createValue(style.display()); 1860 return cssValuePool().createValue(style.display());
1871 case CSSPropertyEmptyCells: 1861 case CSSPropertyEmptyCells:
1872 return cssValuePool().createValue(style.emptyCells()); 1862 return cssValuePool().createValue(style.emptyCells());
1873 case CSSPropertyAlignContent: 1863 case CSSPropertyAlignContent:
1874 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent()); 1864 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent());
1875 case CSSPropertyAlignItems: 1865 case CSSPropertyAlignItems:
1876 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac yPosition); 1866 return valueForItemPositionWithOverflowAlignment(style.alignItems());
1877 case CSSPropertyAlignSelf: { 1867 case CSSPropertyAlignSelf:
1878 ItemPosition position = style.alignSelfPosition(); 1868 return valueForItemPositionWithOverflowAlignment(style.alignSelf());
1879 if (position == ItemPositionAuto) {
1880 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par entComputedStyle)
1881 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled Node->parentNode()->ensureComputedStyle() : nullptr;
1882 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart;
1883 }
1884 return valueForItemPositionWithOverflowAlignment(position, style.alignSe lfOverflowAlignment(), NonLegacyPosition);
1885 }
1886 case CSSPropertyFlex: 1869 case CSSPropertyFlex:
1887 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); 1870 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle);
1888 case CSSPropertyFlexBasis: 1871 case CSSPropertyFlexBasis:
1889 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); 1872 return zoomAdjustedPixelValueForLength(style.flexBasis(), style);
1890 case CSSPropertyFlexDirection: 1873 case CSSPropertyFlexDirection:
1891 return cssValuePool().createValue(style.flexDirection()); 1874 return cssValuePool().createValue(style.flexDirection());
1892 case CSSPropertyFlexFlow: 1875 case CSSPropertyFlexFlow:
1893 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); 1876 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle);
1894 case CSSPropertyFlexGrow: 1877 case CSSPropertyFlexGrow:
1895 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); 1878 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 return CSSStringValue::create(style.hyphenationString()); 2013 return CSSStringValue::create(style.hyphenationString());
2031 case CSSPropertyImageRendering: 2014 case CSSPropertyImageRendering:
2032 return CSSPrimitiveValue::create(style.imageRendering()); 2015 return CSSPrimitiveValue::create(style.imageRendering());
2033 case CSSPropertyImageOrientation: 2016 case CSSPropertyImageOrientation:
2034 if (style.respectImageOrientation() == RespectImageOrientation) 2017 if (style.respectImageOrientation() == RespectImageOrientation)
2035 return cssValuePool().createIdentifierValue(CSSValueFromImage); 2018 return cssValuePool().createIdentifierValue(CSSValueFromImage);
2036 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s); 2019 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s);
2037 case CSSPropertyIsolation: 2020 case CSSPropertyIsolation:
2038 return cssValuePool().createValue(style.isolation()); 2021 return cssValuePool().createValue(style.isolation());
2039 case CSSPropertyJustifyItems: 2022 case CSSPropertyJustifyItems:
2040 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl e.justifyItemsPositionType()); 2023 return valueForItemPositionWithOverflowAlignment(style.justifyItems());
2041 case CSSPropertyJustifySelf: { 2024 case CSSPropertyJustifySelf:
2042 Node* parent = styledNode->parentNode(); 2025 return valueForItemPositionWithOverflowAlignment(style.justifySelf());
2043 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st yle.justifySelfOverflowAlignment(), NonLegacyPosition);
2044 }
2045 case CSSPropertyLeft: 2026 case CSSPropertyLeft:
2046 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); 2027 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject);
2047 case CSSPropertyLetterSpacing: 2028 case CSSPropertyLetterSpacing:
2048 if (!style.letterSpacing()) 2029 if (!style.letterSpacing())
2049 return cssValuePool().createIdentifierValue(CSSValueNormal); 2030 return cssValuePool().createIdentifierValue(CSSValueNormal);
2050 return zoomAdjustedPixelValue(style.letterSpacing(), style); 2031 return zoomAdjustedPixelValue(style.letterSpacing(), style);
2051 case CSSPropertyWebkitLineClamp: 2032 case CSSPropertyWebkitLineClamp:
2052 if (style.lineClamp().isNone()) 2033 if (style.lineClamp().isNone())
2053 return cssValuePool().createIdentifierValue(CSSValueNone); 2034 return cssValuePool().createIdentifierValue(CSSValueNone);
2054 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number); 2035 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number);
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 case CSSPropertyAll: 2985 case CSSPropertyAll:
3005 return nullptr; 2986 return nullptr;
3006 default: 2987 default:
3007 break; 2988 break;
3008 } 2989 }
3009 ASSERT_NOT_REACHED(); 2990 ASSERT_NOT_REACHED();
3010 return nullptr; 2991 return nullptr;
3011 } 2992 }
3012 2993
3013 } // namespace blink 2994 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698