Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 366 direction = cssValuePool().createIdentifierValue(CSSValueLeft); | 366 direction = cssValuePool().createIdentifierValue(CSSValueLeft); |
| 367 break; | 367 break; |
| 368 case ReflectionRight: | 368 case ReflectionRight: |
| 369 direction = cssValuePool().createIdentifierValue(CSSValueRight); | 369 direction = cssValuePool().createIdentifierValue(CSSValueRight); |
| 370 break; | 370 break; |
| 371 } | 371 } |
| 372 | 372 |
| 373 return CSSReflectValue::create(direction.release(), offset.release(), valueF orNinePieceImage(reflection->mask(), style)); | 373 return CSSReflectValue::create(direction.release(), offset.release(), valueF orNinePieceImage(reflection->mask(), style)); |
| 374 } | 374 } |
| 375 | 375 |
| 376 static ItemPosition resolveAlignmentAuto(ItemPosition position, const ComputedSt yle* style) | 376 static StyleSelfAlignmentData resolveJustifySelfAuto(const StyleSelfAlignmentDat a& data, Node* parent) |
| 377 { | 377 { |
| 378 if (position != ItemPositionAuto) | 378 if (data.position() != ItemPositionAuto) |
| 379 return position; | 379 return data; |
| 380 | |
| 381 // The 'auto' keyword computes to the computed value of justify-items on the parent or 'normal' if the box has no parent. | |
| 382 if (!parent) | |
| 383 return {ItemPositionNormal, OverflowAlignmentDefault}; | |
| 384 return parent->ensureComputedStyle()->justifyItems(); | |
| 385 } | |
| 386 | |
| 387 static StyleSelfAlignmentData resolveAlignSelfAuto(const StyleSelfAlignmentData& data, Node* parent) | |
| 388 { | |
| 389 if (data.position() != ItemPositionAuto) | |
| 390 return data; | |
| 380 | 391 |
| 381 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 392 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 382 return ItemPositionStretch; | 393 return {ItemPositionStretch, OverflowAlignmentDefault}; |
| 383 | 394 |
| 384 return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart; | 395 // The 'auto' keyword computes to the computed value of align-items on the p arent or 'normal' if the box has no parent. |
| 396 if (parent) | |
|
cbiesinger
2016/02/18 20:13:17
I'd prefer if this function were consistent with r
jfernandez
2016/02/18 21:28:57
Acknowledged.
Timothy Loh
2016/02/25 00:23:17
err.. were you going to do this?
jfernandez
2016/02/25 01:52:37
I wanted to get your feedback before providing a n
| |
| 397 return parent->ensureComputedStyle()->alignItems(); | |
| 398 return {ItemPositionNormal, OverflowAlignmentDefault}; | |
| 385 } | 399 } |
| 386 | 400 |
| 387 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi onType positionType) | 401 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig nment(const StyleSelfAlignmentData& data) |
| 388 { | 402 { |
| 389 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); | 403 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); |
| 390 if (positionType == LegacyPosition) | 404 if (data.positionType() == LegacyPosition) |
| 391 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 405 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
| 392 result->append(CSSPrimitiveValue::create(itemPosition)); | 406 result->append(CSSPrimitiveValue::create(data.position())); |
| 393 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign mentDefault) | 407 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig nmentDefault) |
| 394 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 408 result->append(CSSPrimitiveValue::create(data.overflow())); |
| 395 ASSERT(result->length() <= 2); | 409 ASSERT(result->length() <= 2); |
| 396 return result.release(); | 410 return result.release(); |
| 397 } | 411 } |
| 398 | 412 |
| 399 static PassRefPtrWillBeRawPtr<CSSValueList> valuesForGridShorthand(const StylePr opertyShorthand& shorthand, const ComputedStyle& style, const LayoutObject* layo utObject, Node* styledNode, bool allowVisitedStyle) | 413 static PassRefPtrWillBeRawPtr<CSSValueList> valuesForGridShorthand(const StylePr opertyShorthand& shorthand, const ComputedStyle& style, const LayoutObject* layo utObject, Node* styledNode, bool allowVisitedStyle) |
| 400 { | 414 { |
| 401 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated() ; | 415 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated() ; |
| 402 for (size_t i = 0; i < shorthand.length(); ++i) { | 416 for (size_t i = 0; i < shorthand.length(); ++i) { |
| 403 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(s horthand.properties()[i], style, layoutObject, styledNode, allowVisitedStyle); | 417 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(s horthand.properties()[i], style, layoutObject, styledNode, allowVisitedStyle); |
| 404 ASSERT(value); | 418 ASSERT(value); |
| (...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1568 } | 1582 } |
| 1569 case CSSPropertyDirection: | 1583 case CSSPropertyDirection: |
| 1570 return cssValuePool().createValue(style.direction()); | 1584 return cssValuePool().createValue(style.direction()); |
| 1571 case CSSPropertyDisplay: | 1585 case CSSPropertyDisplay: |
| 1572 return cssValuePool().createValue(style.display()); | 1586 return cssValuePool().createValue(style.display()); |
| 1573 case CSSPropertyEmptyCells: | 1587 case CSSPropertyEmptyCells: |
| 1574 return cssValuePool().createValue(style.emptyCells()); | 1588 return cssValuePool().createValue(style.emptyCells()); |
| 1575 case CSSPropertyAlignContent: | 1589 case CSSPropertyAlignContent: |
| 1576 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent()); | 1590 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent()); |
| 1577 case CSSPropertyAlignItems: | 1591 case CSSPropertyAlignItems: |
| 1578 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac yPosition); | 1592 return valueForItemPositionWithOverflowAlignment(style.alignItems()); |
| 1579 case CSSPropertyAlignSelf: { | 1593 case CSSPropertyAlignSelf: |
| 1580 ItemPosition position = style.alignSelfPosition(); | 1594 return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(st yle.alignSelf(), FlatTreeTraversal::parent(*styledNode))); |
| 1581 if (position == ItemPositionAuto) { | |
| 1582 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par entComputedStyle) | |
| 1583 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled Node->parentNode()->ensureComputedStyle() : nullptr; | |
| 1584 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart; | |
| 1585 } | |
| 1586 return valueForItemPositionWithOverflowAlignment(position, style.alignSe lfOverflowAlignment(), NonLegacyPosition); | |
| 1587 } | |
| 1588 case CSSPropertyFlex: | 1595 case CSSPropertyFlex: |
| 1589 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); | 1596 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); |
| 1590 case CSSPropertyFlexBasis: | 1597 case CSSPropertyFlexBasis: |
| 1591 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); | 1598 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); |
| 1592 case CSSPropertyFlexDirection: | 1599 case CSSPropertyFlexDirection: |
| 1593 return cssValuePool().createValue(style.flexDirection()); | 1600 return cssValuePool().createValue(style.flexDirection()); |
| 1594 case CSSPropertyFlexFlow: | 1601 case CSSPropertyFlexFlow: |
| 1595 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); | 1602 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); |
| 1596 case CSSPropertyFlexGrow: | 1603 case CSSPropertyFlexGrow: |
| 1597 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); | 1604 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1730 return CSSStringValue::create(style.hyphenationString()); | 1737 return CSSStringValue::create(style.hyphenationString()); |
| 1731 case CSSPropertyImageRendering: | 1738 case CSSPropertyImageRendering: |
| 1732 return CSSPrimitiveValue::create(style.imageRendering()); | 1739 return CSSPrimitiveValue::create(style.imageRendering()); |
| 1733 case CSSPropertyImageOrientation: | 1740 case CSSPropertyImageOrientation: |
| 1734 if (style.respectImageOrientation() == RespectImageOrientation) | 1741 if (style.respectImageOrientation() == RespectImageOrientation) |
| 1735 return cssValuePool().createIdentifierValue(CSSValueFromImage); | 1742 return cssValuePool().createIdentifierValue(CSSValueFromImage); |
| 1736 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s); | 1743 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s); |
| 1737 case CSSPropertyIsolation: | 1744 case CSSPropertyIsolation: |
| 1738 return cssValuePool().createValue(style.isolation()); | 1745 return cssValuePool().createValue(style.isolation()); |
| 1739 case CSSPropertyJustifyItems: | 1746 case CSSPropertyJustifyItems: |
| 1740 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl e.justifyItemsPositionType()); | 1747 return valueForItemPositionWithOverflowAlignment(style.justifyItems()); |
| 1741 case CSSPropertyJustifySelf: { | 1748 case CSSPropertyJustifySelf: |
| 1742 Node* parent = styledNode->parentNode(); | 1749 return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto( style.justifySelf(), FlatTreeTraversal::parent(*styledNode))); |
| 1743 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st yle.justifySelfOverflowAlignment(), NonLegacyPosition); | |
| 1744 } | |
| 1745 case CSSPropertyLeft: | 1750 case CSSPropertyLeft: |
| 1746 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); | 1751 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); |
| 1747 case CSSPropertyLetterSpacing: | 1752 case CSSPropertyLetterSpacing: |
| 1748 if (!style.letterSpacing()) | 1753 if (!style.letterSpacing()) |
| 1749 return cssValuePool().createIdentifierValue(CSSValueNormal); | 1754 return cssValuePool().createIdentifierValue(CSSValueNormal); |
| 1750 return zoomAdjustedPixelValue(style.letterSpacing(), style); | 1755 return zoomAdjustedPixelValue(style.letterSpacing(), style); |
| 1751 case CSSPropertyWebkitLineClamp: | 1756 case CSSPropertyWebkitLineClamp: |
| 1752 if (style.lineClamp().isNone()) | 1757 if (style.lineClamp().isNone()) |
| 1753 return cssValuePool().createIdentifierValue(CSSValueNone); | 1758 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 1754 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number); | 1759 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 Loading... | |
| 2704 case CSSPropertyAll: | 2709 case CSSPropertyAll: |
| 2705 return nullptr; | 2710 return nullptr; |
| 2706 default: | 2711 default: |
| 2707 break; | 2712 break; |
| 2708 } | 2713 } |
| 2709 ASSERT_NOT_REACHED(); | 2714 ASSERT_NOT_REACHED(); |
| 2710 return nullptr; | 2715 return nullptr; |
| 2711 } | 2716 } |
| 2712 | 2717 |
| 2713 } // namespace blink | 2718 } // namespace blink |
| OLD | NEW |