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 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Lesser General Public | 9 * modify it under the terms of the GNU Lesser General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 { | 1549 { |
1550 if (!m_node) | 1550 if (!m_node) |
1551 return 0; | 1551 return 0; |
1552 if (m_node->isElementNode()) { | 1552 if (m_node->isElementNode()) { |
1553 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) | 1553 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) |
1554 return element; | 1554 return element; |
1555 } | 1555 } |
1556 return m_node.get(); | 1556 return m_node.get(); |
1557 } | 1557 } |
1558 | 1558 |
| 1559 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) |
| 1560 { |
| 1561 if (position != ItemPositionAuto) |
| 1562 return position; |
| 1563 |
| 1564 bool isFlexOrGrid = element && element->computedStyle() |
| 1565 && element->computedStyle()->isDisplayFlexibleOrGridBox(); |
| 1566 |
| 1567 return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart; |
| 1568 } |
| 1569 |
1559 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) | 1570 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) |
1560 { | 1571 { |
1561 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 1572 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
1562 if (positionType == LegacyPosition) | 1573 if (positionType == LegacyPosition) |
1563 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 1574 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
1564 result->append(CSSPrimitiveValue::create(itemPosition)); | 1575 result->append(CSSPrimitiveValue::create(itemPosition)); |
1565 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 1576 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) |
1566 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 1577 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
1567 ASSERT(result->length() <= 2); | 1578 ASSERT(result->length() <= 2); |
1568 return result.release(); | 1579 return result.release(); |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 } | 1890 } |
1880 case CSSPropertyDirection: | 1891 case CSSPropertyDirection: |
1881 return cssValuePool().createValue(style->direction()); | 1892 return cssValuePool().createValue(style->direction()); |
1882 case CSSPropertyDisplay: | 1893 case CSSPropertyDisplay: |
1883 return cssValuePool().createValue(style->display()); | 1894 return cssValuePool().createValue(style->display()); |
1884 case CSSPropertyEmptyCells: | 1895 case CSSPropertyEmptyCells: |
1885 return cssValuePool().createValue(style->emptyCells()); | 1896 return cssValuePool().createValue(style->emptyCells()); |
1886 case CSSPropertyAlignContent: | 1897 case CSSPropertyAlignContent: |
1887 return cssValuePool().createValue(style->alignContent()); | 1898 return cssValuePool().createValue(style->alignContent()); |
1888 case CSSPropertyAlignItems: | 1899 case CSSPropertyAlignItems: |
1889 return valueForItemPositionWithOverflowAlignment(style->alignItems()
, style->alignItemsOverflowAlignment(), NonLegacyPosition); | 1900 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAut
o(style->alignItems(), styledNode), style->alignItemsOverflowAlignment(), NonLeg
acyPosition); |
1890 case CSSPropertyAlignSelf: { | 1901 case CSSPropertyAlignSelf: |
1891 ItemPosition alignSelf = style->alignSelf(); | 1902 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAut
o(style->alignSelf(), styledNode->parentNode()), style->alignSelfOverflowAlignme
nt(), NonLegacyPosition); |
1892 if (alignSelf == ItemPositionAuto) { | |
1893 Node* parent = styledNode->parentNode(); | |
1894 if (parent && parent->computedStyle()) | |
1895 alignSelf = parent->computedStyle()->alignItems(); | |
1896 else | |
1897 alignSelf = ItemPositionStretch; | |
1898 } | |
1899 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a
lignSelfOverflowAlignment(), NonLegacyPosition); | |
1900 } | |
1901 case CSSPropertyFlex: | 1903 case CSSPropertyFlex: |
1902 return valuesForShorthandProperty(flexShorthand()); | 1904 return valuesForShorthandProperty(flexShorthand()); |
1903 case CSSPropertyFlexBasis: | 1905 case CSSPropertyFlexBasis: |
1904 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); | 1906 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); |
1905 case CSSPropertyFlexDirection: | 1907 case CSSPropertyFlexDirection: |
1906 return cssValuePool().createValue(style->flexDirection()); | 1908 return cssValuePool().createValue(style->flexDirection()); |
1907 case CSSPropertyFlexFlow: | 1909 case CSSPropertyFlexFlow: |
1908 return valuesForShorthandProperty(flexFlowShorthand()); | 1910 return valuesForShorthandProperty(flexFlowShorthand()); |
1909 case CSSPropertyFlexGrow: | 1911 case CSSPropertyFlexGrow: |
1910 return cssValuePool().createValue(style->flexGrow()); | 1912 return cssValuePool().createValue(style->flexGrow()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 return cssValuePool().createIdentifierValue(CSSValueAuto); | 2056 return cssValuePool().createIdentifierValue(CSSValueAuto); |
2055 return cssValuePool().createValue(style->hyphenationString(), CSSPri
mitiveValue::CSS_STRING); | 2057 return cssValuePool().createValue(style->hyphenationString(), CSSPri
mitiveValue::CSS_STRING); |
2056 case CSSPropertyWebkitBorderFit: | 2058 case CSSPropertyWebkitBorderFit: |
2057 if (style->borderFit() == BorderFitBorder) | 2059 if (style->borderFit() == BorderFitBorder) |
2058 return cssValuePool().createIdentifierValue(CSSValueBorder); | 2060 return cssValuePool().createIdentifierValue(CSSValueBorder); |
2059 return cssValuePool().createIdentifierValue(CSSValueLines); | 2061 return cssValuePool().createIdentifierValue(CSSValueLines); |
2060 case CSSPropertyImageRendering: | 2062 case CSSPropertyImageRendering: |
2061 return CSSPrimitiveValue::create(style->imageRendering()); | 2063 return CSSPrimitiveValue::create(style->imageRendering()); |
2062 case CSSPropertyIsolation: | 2064 case CSSPropertyIsolation: |
2063 return cssValuePool().createValue(style->isolation()); | 2065 return cssValuePool().createValue(style->isolation()); |
2064 case CSSPropertyJustifyItems: { | 2066 case CSSPropertyJustifyItems: |
2065 // FIXME: I would like this to be tested; is not possible with a lay
out test but it | 2067 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAut
o(style->justifyItems(), styledNode), style->justifyItemsOverflowAlignment(), st
yle->justifyItemsPositionType()); |
2066 // should be possible using a method similar to https://codereview.c
hromium.org/351973004 | 2068 case CSSPropertyJustifySelf: |
2067 ItemPosition justifyItems = style->justifyItems(); | 2069 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAut
o(style->justifySelf(), styledNode->parentNode()), style->justifySelfOverflowAli
gnment(), NonLegacyPosition); |
2068 ItemPositionType positionType = style->justifyItemsPositionType(); | |
2069 if (justifyItems == ItemPositionAuto) { | |
2070 Node* parent = styledNode->parentNode(); | |
2071 // If the inherited value of justify-items includes the legacy k
eyword, 'auto' | |
2072 // computes to the the inherited value. | |
2073 if (parent && parent->computedStyle() && parent->computedStyle()
->justifyItemsPositionType()) { | |
2074 justifyItems = parent->computedStyle()->justifyItems(); | |
2075 positionType = parent->computedStyle()->justifyItemsPosition
Type(); | |
2076 // Otherwise, auto computes to: | |
2077 } else if (style->isDisplayFlexibleOrGridBox()) { | |
2078 // 'stretch' for flex containers and grid containers. | |
2079 justifyItems = ItemPositionStretch; | |
2080 } else { | |
2081 // 'start' for everything else. | |
2082 justifyItems = ItemPositionStart; | |
2083 } | |
2084 } | |
2085 return valueForItemPositionWithOverflowAlignment(justifyItems, style
->justifyItemsOverflowAlignment(), positionType); | |
2086 } | |
2087 case CSSPropertyJustifySelf: { | |
2088 // FIXME: I would like this to be tested; is not possible with a lay
out test but it | |
2089 // should be possible using a method similar to https://codereview.c
hromium.org/351973004 | |
2090 ItemPosition justifySelf = style->justifySelf(); | |
2091 if (justifySelf == ItemPositionAuto) { | |
2092 // The auto keyword computes to stretch on absolutely-positioned
elements, | |
2093 if (style->position() == AbsolutePosition) { | |
2094 justifySelf = ItemPositionStretch; | |
2095 } else { | |
2096 // and to the computed value of justify-items on the parent
(minus | |
2097 // any legacy keywords) on all other boxes. | |
2098 Node* parent = styledNode->parentNode(); | |
2099 if (parent && parent->computedStyle()) | |
2100 justifySelf = parent->computedStyle()->justifyItems(); | |
2101 } | |
2102 } | |
2103 return valueForItemPositionWithOverflowAlignment(justifySelf, style-
>justifySelfOverflowAlignment(), NonLegacyPosition); | |
2104 } | |
2105 case CSSPropertyLeft: | 2070 case CSSPropertyLeft: |
2106 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); | 2071 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); |
2107 case CSSPropertyLetterSpacing: | 2072 case CSSPropertyLetterSpacing: |
2108 if (!style->letterSpacing()) | 2073 if (!style->letterSpacing()) |
2109 return cssValuePool().createIdentifierValue(CSSValueNormal); | 2074 return cssValuePool().createIdentifierValue(CSSValueNormal); |
2110 return zoomAdjustedPixelValue(style->letterSpacing(), *style); | 2075 return zoomAdjustedPixelValue(style->letterSpacing(), *style); |
2111 case CSSPropertyWebkitLineClamp: | 2076 case CSSPropertyWebkitLineClamp: |
2112 if (style->lineClamp().isNone()) | 2077 if (style->lineClamp().isNone()) |
2113 return cssValuePool().createIdentifierValue(CSSValueNone); | 2078 return cssValuePool().createIdentifierValue(CSSValueNone); |
2114 return cssValuePool().createValue(style->lineClamp().value(), style-
>lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa
lue::CSS_NUMBER); | 2079 return cssValuePool().createValue(style->lineClamp().value(), style-
>lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa
lue::CSS_NUMBER); |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3129 return list.release(); | 3094 return list.release(); |
3130 } | 3095 } |
3131 | 3096 |
3132 void CSSComputedStyleDeclaration::trace(Visitor* visitor) | 3097 void CSSComputedStyleDeclaration::trace(Visitor* visitor) |
3133 { | 3098 { |
3134 visitor->trace(m_node); | 3099 visitor->trace(m_node); |
3135 CSSStyleDeclaration::trace(visitor); | 3100 CSSStyleDeclaration::trace(visitor); |
3136 } | 3101 } |
3137 | 3102 |
3138 } // namespace blink | 3103 } // namespace blink |
OLD | NEW |