| 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 resolveLegacyJustifyItems(const StyleSelfAlignment
Data& data) |
| 377 { | 377 { |
| 378 if (position != ItemPositionAuto) | 378 if (data.positionType() == LegacyPosition) |
| 379 return position; | 379 return {data.position(), OverflowAlignmentDefault}; |
| 380 return data; |
| 381 } |
| 382 |
| 383 static StyleSelfAlignmentData resolveJustifyItemsAuto(const StyleSelfAlignmentDa
ta& data, Node* parent) |
| 384 { |
| 385 if (data.position() != ItemPositionAuto) |
| 386 return data; |
| 387 |
| 388 // If the inherited value of justify-items includes the 'legacy' keyword, 'a
uto' computes to the inherited value. |
| 389 const StyleSelfAlignmentData& inheritedValue = isTreeScopeRoot(parent) ? Com
putedStyle::initialDefaultAlignment() : parent->ensureComputedStyle()->justifyIt
ems(); |
| 390 if (inheritedValue.positionType() == LegacyPosition) |
| 391 return inheritedValue; |
| 392 if (inheritedValue.position() == ItemPositionAuto) |
| 393 return resolveJustifyItemsAuto(inheritedValue, FlatTreeTraversal::parent
(*parent)); |
| 394 return {ItemPositionNormal, OverflowAlignmentDefault}; |
| 395 } |
| 396 |
| 397 static StyleSelfAlignmentData resolveJustifySelfAuto(const StyleSelfAlignmentDat
a& data, Node* parent) |
| 398 { |
| 399 if (data.position() != ItemPositionAuto) |
| 400 return data; |
| 401 |
| 402 // The 'auto' keyword computes to the computed value of justify-items on the
parent or 'normal' if the box has no parent. |
| 403 if (isTreeScopeRoot(parent)) |
| 404 return {ItemPositionNormal, OverflowAlignmentDefault}; |
| 405 return resolveLegacyJustifyItems(resolveJustifyItemsAuto(parent->ensureCompu
tedStyle()->justifyItems(), FlatTreeTraversal::parent(*parent))); |
| 406 } |
| 407 |
| 408 static StyleSelfAlignmentData resolveAlignSelfAuto(const StyleSelfAlignmentData&
data, Node* parent) |
| 409 { |
| 410 if (data.position() != ItemPositionAuto) |
| 411 return data; |
| 380 | 412 |
| 381 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | 413 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) |
| 382 return ItemPositionStretch; | 414 return {ItemPositionStretch, OverflowAlignmentDefault}; |
| 383 | 415 |
| 384 return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart; | 416 // The 'auto' keyword computes to the computed value of align-items on the p
arent or 'normal' if the box has no parent. |
| 417 if (isTreeScopeRoot(parent)) |
| 418 return {ItemPositionNormal, OverflowAlignmentDefault}; |
| 419 return parent->ensureComputedStyle()->alignItems(); |
| 385 } | 420 } |
| 386 | 421 |
| 387 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) | 422 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(const StyleSelfAlignmentData& data) |
| 388 { | 423 { |
| 389 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 424 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
| 390 if (positionType == LegacyPosition) | 425 if (data.positionType() == LegacyPosition) |
| 391 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 426 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
| 392 result->append(CSSPrimitiveValue::create(itemPosition)); | 427 result->append(CSSPrimitiveValue::create(data.position())); |
| 393 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 428 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig
nmentDefault) |
| 394 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 429 result->append(CSSPrimitiveValue::create(data.overflow())); |
| 395 ASSERT(result->length() <= 2); | 430 ASSERT(result->length() <= 2); |
| 396 return result.release(); | 431 return result.release(); |
| 397 } | 432 } |
| 398 | 433 |
| 399 static PassRefPtrWillBeRawPtr<CSSValueList> valuesForGridShorthand(const StylePr
opertyShorthand& shorthand, const ComputedStyle& style, const LayoutObject* layo
utObject, Node* styledNode, bool allowVisitedStyle) | 434 static PassRefPtrWillBeRawPtr<CSSValueList> valuesForGridShorthand(const StylePr
opertyShorthand& shorthand, const ComputedStyle& style, const LayoutObject* layo
utObject, Node* styledNode, bool allowVisitedStyle) |
| 400 { | 435 { |
| 401 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated()
; | 436 RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated()
; |
| 402 for (size_t i = 0; i < shorthand.length(); ++i) { | 437 for (size_t i = 0; i < shorthand.length(); ++i) { |
| 403 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(s
horthand.properties()[i], style, layoutObject, styledNode, allowVisitedStyle); | 438 RefPtrWillBeRawPtr<CSSValue> value = ComputedStyleCSSValueMapping::get(s
horthand.properties()[i], style, layoutObject, styledNode, allowVisitedStyle); |
| 404 ASSERT(value); | 439 ASSERT(value); |
| (...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 } | 1639 } |
| 1605 case CSSPropertyDirection: | 1640 case CSSPropertyDirection: |
| 1606 return cssValuePool().createValue(style.direction()); | 1641 return cssValuePool().createValue(style.direction()); |
| 1607 case CSSPropertyDisplay: | 1642 case CSSPropertyDisplay: |
| 1608 return cssValuePool().createValue(style.display()); | 1643 return cssValuePool().createValue(style.display()); |
| 1609 case CSSPropertyEmptyCells: | 1644 case CSSPropertyEmptyCells: |
| 1610 return cssValuePool().createValue(style.emptyCells()); | 1645 return cssValuePool().createValue(style.emptyCells()); |
| 1611 case CSSPropertyAlignContent: | 1646 case CSSPropertyAlignContent: |
| 1612 return valueForContentPositionAndDistributionWithOverflowAlignment(style
.alignContent()); | 1647 return valueForContentPositionAndDistributionWithOverflowAlignment(style
.alignContent()); |
| 1613 case CSSPropertyAlignItems: | 1648 case CSSPropertyAlignItems: |
| 1614 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac
yPosition); | 1649 return valueForItemPositionWithOverflowAlignment(style.alignItems()); |
| 1615 case CSSPropertyAlignSelf: { | 1650 case CSSPropertyAlignSelf: |
| 1616 ItemPosition position = style.alignSelfPosition(); | 1651 return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(st
yle.alignSelf(), FlatTreeTraversal::parent(*styledNode))); |
| 1617 if (position == ItemPositionAuto) { | |
| 1618 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par
entComputedStyle) | |
| 1619 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled
Node->parentNode()->ensureComputedStyle() : nullptr; | |
| 1620 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl
e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle))
: ItemPositionStart; | |
| 1621 } | |
| 1622 return valueForItemPositionWithOverflowAlignment(position, style.alignSe
lfOverflowAlignment(), NonLegacyPosition); | |
| 1623 } | |
| 1624 case CSSPropertyFlex: | 1652 case CSSPropertyFlex: |
| 1625 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); | 1653 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); |
| 1626 case CSSPropertyFlexBasis: | 1654 case CSSPropertyFlexBasis: |
| 1627 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); | 1655 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); |
| 1628 case CSSPropertyFlexDirection: | 1656 case CSSPropertyFlexDirection: |
| 1629 return cssValuePool().createValue(style.flexDirection()); | 1657 return cssValuePool().createValue(style.flexDirection()); |
| 1630 case CSSPropertyFlexFlow: | 1658 case CSSPropertyFlexFlow: |
| 1631 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); | 1659 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); |
| 1632 case CSSPropertyFlexGrow: | 1660 case CSSPropertyFlexGrow: |
| 1633 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U
nitType::Number); | 1661 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U
nitType::Number); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 return CSSStringValue::create(style.hyphenationString()); | 1794 return CSSStringValue::create(style.hyphenationString()); |
| 1767 case CSSPropertyImageRendering: | 1795 case CSSPropertyImageRendering: |
| 1768 return CSSPrimitiveValue::create(style.imageRendering()); | 1796 return CSSPrimitiveValue::create(style.imageRendering()); |
| 1769 case CSSPropertyImageOrientation: | 1797 case CSSPropertyImageOrientation: |
| 1770 if (style.respectImageOrientation() == RespectImageOrientation) | 1798 if (style.respectImageOrientation() == RespectImageOrientation) |
| 1771 return cssValuePool().createIdentifierValue(CSSValueFromImage); | 1799 return cssValuePool().createIdentifierValue(CSSValueFromImage); |
| 1772 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree
s); | 1800 return cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Degree
s); |
| 1773 case CSSPropertyIsolation: | 1801 case CSSPropertyIsolation: |
| 1774 return cssValuePool().createValue(style.isolation()); | 1802 return cssValuePool().createValue(style.isolation()); |
| 1775 case CSSPropertyJustifyItems: | 1803 case CSSPropertyJustifyItems: |
| 1776 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl
e.justifyItemsPositionType()); | 1804 return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto
(style.justifyItems(), FlatTreeTraversal::parent(*styledNode))); |
| 1777 case CSSPropertyJustifySelf: { | 1805 case CSSPropertyJustifySelf: |
| 1778 Node* parent = styledNode->parentNode(); | 1806 return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(
style.justifySelf(), FlatTreeTraversal::parent(*styledNode))); |
| 1779 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st
yle.justifySelfOverflowAlignment(), NonLegacyPosition); | |
| 1780 } | |
| 1781 case CSSPropertyLeft: | 1807 case CSSPropertyLeft: |
| 1782 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); | 1808 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); |
| 1783 case CSSPropertyLetterSpacing: | 1809 case CSSPropertyLetterSpacing: |
| 1784 if (!style.letterSpacing()) | 1810 if (!style.letterSpacing()) |
| 1785 return cssValuePool().createIdentifierValue(CSSValueNormal); | 1811 return cssValuePool().createIdentifierValue(CSSValueNormal); |
| 1786 return zoomAdjustedPixelValue(style.letterSpacing(), style); | 1812 return zoomAdjustedPixelValue(style.letterSpacing(), style); |
| 1787 case CSSPropertyWebkitLineClamp: | 1813 case CSSPropertyWebkitLineClamp: |
| 1788 if (style.lineClamp().isNone()) | 1814 if (style.lineClamp().isNone()) |
| 1789 return cssValuePool().createIdentifierValue(CSSValueNone); | 1815 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 1790 return cssValuePool().createValue(style.lineClamp().value(), style.lineC
lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa
lue::UnitType::Number); | 1816 return cssValuePool().createValue(style.lineClamp().value(), style.lineC
lamp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVa
lue::UnitType::Number); |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2750 case CSSPropertyAll: | 2776 case CSSPropertyAll: |
| 2751 return nullptr; | 2777 return nullptr; |
| 2752 default: | 2778 default: |
| 2753 break; | 2779 break; |
| 2754 } | 2780 } |
| 2755 ASSERT_NOT_REACHED(); | 2781 ASSERT_NOT_REACHED(); |
| 2756 return nullptr; | 2782 return nullptr; |
| 2757 } | 2783 } |
| 2758 | 2784 |
| 2759 } // namespace blink | 2785 } // namespace blink |
| OLD | NEW |