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 (isTreeScopeRoot(parent)) | |
kochi
2016/03/18 05:19:03
As FlatTreeTraversal::parent() returns shadow host
jfernandez
2016/03/18 13:54:54
This is an interesting question, I don't think it'
| |
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 (isTreeScopeRoot(parent)) | |
397 return {ItemPositionNormal, OverflowAlignmentDefault}; | |
398 return parent->ensureComputedStyle()->alignItems(); | |
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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1606 } | 1620 } |
1607 case CSSPropertyDirection: | 1621 case CSSPropertyDirection: |
1608 return cssValuePool().createValue(style.direction()); | 1622 return cssValuePool().createValue(style.direction()); |
1609 case CSSPropertyDisplay: | 1623 case CSSPropertyDisplay: |
1610 return cssValuePool().createValue(style.display()); | 1624 return cssValuePool().createValue(style.display()); |
1611 case CSSPropertyEmptyCells: | 1625 case CSSPropertyEmptyCells: |
1612 return cssValuePool().createValue(style.emptyCells()); | 1626 return cssValuePool().createValue(style.emptyCells()); |
1613 case CSSPropertyAlignContent: | 1627 case CSSPropertyAlignContent: |
1614 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent()); | 1628 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent()); |
1615 case CSSPropertyAlignItems: | 1629 case CSSPropertyAlignItems: |
1616 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac yPosition); | 1630 return valueForItemPositionWithOverflowAlignment(style.alignItems()); |
1617 case CSSPropertyAlignSelf: { | 1631 case CSSPropertyAlignSelf: |
1618 ItemPosition position = style.alignSelfPosition(); | 1632 return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(st yle.alignSelf(), FlatTreeTraversal::parent(*styledNode))); |
1619 if (position == ItemPositionAuto) { | |
1620 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par entComputedStyle) | |
1621 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled Node->parentNode()->ensureComputedStyle() : nullptr; | |
1622 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart; | |
1623 } | |
1624 return valueForItemPositionWithOverflowAlignment(position, style.alignSe lfOverflowAlignment(), NonLegacyPosition); | |
1625 } | |
1626 case CSSPropertyFlex: | 1633 case CSSPropertyFlex: |
1627 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); | 1634 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); |
1628 case CSSPropertyFlexBasis: | 1635 case CSSPropertyFlexBasis: |
1629 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); | 1636 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); |
1630 case CSSPropertyFlexDirection: | 1637 case CSSPropertyFlexDirection: |
1631 return cssValuePool().createValue(style.flexDirection()); | 1638 return cssValuePool().createValue(style.flexDirection()); |
1632 case CSSPropertyFlexFlow: | 1639 case CSSPropertyFlexFlow: |
1633 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); | 1640 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); |
1634 case CSSPropertyFlexGrow: | 1641 case CSSPropertyFlexGrow: |
1635 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); | 1642 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1768 return CSSStringValue::create(style.hyphenationString()); | 1775 return CSSStringValue::create(style.hyphenationString()); |
1769 case CSSPropertyImageRendering: | 1776 case CSSPropertyImageRendering: |
1770 return CSSPrimitiveValue::create(style.imageRendering()); | 1777 return CSSPrimitiveValue::create(style.imageRendering()); |
1771 case CSSPropertyImageOrientation: | 1778 case CSSPropertyImageOrientation: |
1772 if (style.respectImageOrientation() == RespectImageOrientation) | 1779 if (style.respectImageOrientation() == RespectImageOrientation) |
1773 return cssValuePool().createIdentifierValue(CSSValueFromImage); | 1780 return cssValuePool().createIdentifierValue(CSSValueFromImage); |
1774 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s); | 1781 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree s); |
1775 case CSSPropertyIsolation: | 1782 case CSSPropertyIsolation: |
1776 return cssValuePool().createValue(style.isolation()); | 1783 return cssValuePool().createValue(style.isolation()); |
1777 case CSSPropertyJustifyItems: | 1784 case CSSPropertyJustifyItems: |
1778 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl e.justifyItemsPositionType()); | 1785 return valueForItemPositionWithOverflowAlignment(style.justifyItems()); |
1779 case CSSPropertyJustifySelf: { | 1786 case CSSPropertyJustifySelf: |
1780 Node* parent = styledNode->parentNode(); | 1787 return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto( style.justifySelf(), FlatTreeTraversal::parent(*styledNode))); |
1781 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st yle.justifySelfOverflowAlignment(), NonLegacyPosition); | |
1782 } | |
1783 case CSSPropertyLeft: | 1788 case CSSPropertyLeft: |
1784 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); | 1789 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); |
1785 case CSSPropertyLetterSpacing: | 1790 case CSSPropertyLetterSpacing: |
1786 if (!style.letterSpacing()) | 1791 if (!style.letterSpacing()) |
1787 return cssValuePool().createIdentifierValue(CSSValueNormal); | 1792 return cssValuePool().createIdentifierValue(CSSValueNormal); |
1788 return zoomAdjustedPixelValue(style.letterSpacing(), style); | 1793 return zoomAdjustedPixelValue(style.letterSpacing(), style); |
1789 case CSSPropertyWebkitLineClamp: | 1794 case CSSPropertyWebkitLineClamp: |
1790 if (style.lineClamp().isNone()) | 1795 if (style.lineClamp().isNone()) |
1791 return cssValuePool().createIdentifierValue(CSSValueNone); | 1796 return cssValuePool().createIdentifierValue(CSSValueNone); |
1792 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number); | 1797 return cssValuePool().createValue(style.lineClamp().value(), style.lineC lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa lue::UnitType::Number); |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2754 case CSSPropertyAll: | 2759 case CSSPropertyAll: |
2755 return nullptr; | 2760 return nullptr; |
2756 default: | 2761 default: |
2757 break; | 2762 break; |
2758 } | 2763 } |
2759 ASSERT_NOT_REACHED(); | 2764 ASSERT_NOT_REACHED(); |
2760 return nullptr; | 2765 return nullptr; |
2761 } | 2766 } |
2762 | 2767 |
2763 } // namespace blink | 2768 } // namespace blink |
OLD | NEW |