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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 CSSPropertyFontFamily, | 129 CSSPropertyFontFamily, |
130 CSSPropertyFontKerning, | 130 CSSPropertyFontKerning, |
131 CSSPropertyFontSize, | 131 CSSPropertyFontSize, |
132 CSSPropertyFontStyle, | 132 CSSPropertyFontStyle, |
133 CSSPropertyFontVariant, | 133 CSSPropertyFontVariant, |
134 CSSPropertyFontVariantLigatures, | 134 CSSPropertyFontVariantLigatures, |
135 CSSPropertyFontWeight, | 135 CSSPropertyFontWeight, |
136 CSSPropertyHeight, | 136 CSSPropertyHeight, |
137 CSSPropertyImageRendering, | 137 CSSPropertyImageRendering, |
138 CSSPropertyIsolation, | 138 CSSPropertyIsolation, |
| 139 CSSPropertyJustifyItems, |
139 CSSPropertyJustifySelf, | 140 CSSPropertyJustifySelf, |
140 CSSPropertyLeft, | 141 CSSPropertyLeft, |
141 CSSPropertyLetterSpacing, | 142 CSSPropertyLetterSpacing, |
142 CSSPropertyLineHeight, | 143 CSSPropertyLineHeight, |
143 CSSPropertyListStyleImage, | 144 CSSPropertyListStyleImage, |
144 CSSPropertyListStylePosition, | 145 CSSPropertyListStylePosition, |
145 CSSPropertyListStyleType, | 146 CSSPropertyListStyleType, |
146 CSSPropertyMarginBottom, | 147 CSSPropertyMarginBottom, |
147 CSSPropertyMarginLeft, | 148 CSSPropertyMarginLeft, |
148 CSSPropertyMarginRight, | 149 CSSPropertyMarginRight, |
(...skipping 1398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1547 { | 1548 { |
1548 if (!m_node) | 1549 if (!m_node) |
1549 return 0; | 1550 return 0; |
1550 if (m_node->isElementNode()) { | 1551 if (m_node->isElementNode()) { |
1551 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) | 1552 if (PseudoElement* element = toElement(m_node)->pseudoElement(m_pseudoEl
ementSpecifier)) |
1552 return element; | 1553 return element; |
1553 } | 1554 } |
1554 return m_node.get(); | 1555 return m_node.get(); |
1555 } | 1556 } |
1556 | 1557 |
1557 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment) | 1558 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) |
1558 { | 1559 { |
1559 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 1560 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
| 1561 if (positionType == LegacyPosition) |
| 1562 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
1560 result->append(CSSPrimitiveValue::create(itemPosition)); | 1563 result->append(CSSPrimitiveValue::create(itemPosition)); |
1561 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 1564 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) |
1562 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 1565 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
| 1566 ASSERT(result->length() <= 2); |
1563 return result.release(); | 1567 return result.release(); |
1564 } | 1568 } |
1565 | 1569 |
1566 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const | 1570 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const |
1567 { | 1571 { |
1568 Node* styledNode = this->styledNode(); | 1572 Node* styledNode = this->styledNode(); |
1569 if (!styledNode) | 1573 if (!styledNode) |
1570 return nullptr; | 1574 return nullptr; |
1571 RenderObject* renderer = styledNode->renderer(); | 1575 RenderObject* renderer = styledNode->renderer(); |
1572 RefPtr<RenderStyle> style; | 1576 RefPtr<RenderStyle> style; |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1879 } | 1883 } |
1880 case CSSPropertyDirection: | 1884 case CSSPropertyDirection: |
1881 return cssValuePool().createValue(style->direction()); | 1885 return cssValuePool().createValue(style->direction()); |
1882 case CSSPropertyDisplay: | 1886 case CSSPropertyDisplay: |
1883 return cssValuePool().createValue(style->display()); | 1887 return cssValuePool().createValue(style->display()); |
1884 case CSSPropertyEmptyCells: | 1888 case CSSPropertyEmptyCells: |
1885 return cssValuePool().createValue(style->emptyCells()); | 1889 return cssValuePool().createValue(style->emptyCells()); |
1886 case CSSPropertyAlignContent: | 1890 case CSSPropertyAlignContent: |
1887 return cssValuePool().createValue(style->alignContent()); | 1891 return cssValuePool().createValue(style->alignContent()); |
1888 case CSSPropertyAlignItems: | 1892 case CSSPropertyAlignItems: |
1889 return valueForItemPositionWithOverflowAlignment(style->alignItems()
, style->alignItemsOverflowAlignment()); | 1893 return valueForItemPositionWithOverflowAlignment(style->alignItems()
, style->alignItemsOverflowAlignment(), NonLegacyPosition); |
1890 case CSSPropertyAlignSelf: { | 1894 case CSSPropertyAlignSelf: { |
1891 ItemPosition alignSelf = style->alignSelf(); | 1895 ItemPosition alignSelf = style->alignSelf(); |
1892 if (alignSelf == ItemPositionAuto) { | 1896 if (alignSelf == ItemPositionAuto) { |
1893 Node* parent = styledNode->parentNode(); | 1897 Node* parent = styledNode->parentNode(); |
1894 if (parent && parent->computedStyle()) | 1898 if (parent && parent->computedStyle()) |
1895 alignSelf = parent->computedStyle()->alignItems(); | 1899 alignSelf = parent->computedStyle()->alignItems(); |
1896 else | 1900 else |
1897 alignSelf = ItemPositionStretch; | 1901 alignSelf = ItemPositionStretch; |
1898 } | 1902 } |
1899 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a
lignSelfOverflowAlignment()); | 1903 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a
lignSelfOverflowAlignment(), NonLegacyPosition); |
1900 } | 1904 } |
1901 case CSSPropertyFlex: | 1905 case CSSPropertyFlex: |
1902 return valuesForShorthandProperty(flexShorthand()); | 1906 return valuesForShorthandProperty(flexShorthand()); |
1903 case CSSPropertyFlexBasis: | 1907 case CSSPropertyFlexBasis: |
1904 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); | 1908 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); |
1905 case CSSPropertyFlexDirection: | 1909 case CSSPropertyFlexDirection: |
1906 return cssValuePool().createValue(style->flexDirection()); | 1910 return cssValuePool().createValue(style->flexDirection()); |
1907 case CSSPropertyFlexFlow: | 1911 case CSSPropertyFlexFlow: |
1908 return valuesForShorthandProperty(flexFlowShorthand()); | 1912 return valuesForShorthandProperty(flexFlowShorthand()); |
1909 case CSSPropertyFlexGrow: | 1913 case CSSPropertyFlexGrow: |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 return cssValuePool().createIdentifierValue(CSSValueAuto); | 2058 return cssValuePool().createIdentifierValue(CSSValueAuto); |
2055 return cssValuePool().createValue(style->hyphenationString(), CSSPri
mitiveValue::CSS_STRING); | 2059 return cssValuePool().createValue(style->hyphenationString(), CSSPri
mitiveValue::CSS_STRING); |
2056 case CSSPropertyWebkitBorderFit: | 2060 case CSSPropertyWebkitBorderFit: |
2057 if (style->borderFit() == BorderFitBorder) | 2061 if (style->borderFit() == BorderFitBorder) |
2058 return cssValuePool().createIdentifierValue(CSSValueBorder); | 2062 return cssValuePool().createIdentifierValue(CSSValueBorder); |
2059 return cssValuePool().createIdentifierValue(CSSValueLines); | 2063 return cssValuePool().createIdentifierValue(CSSValueLines); |
2060 case CSSPropertyImageRendering: | 2064 case CSSPropertyImageRendering: |
2061 return CSSPrimitiveValue::create(style->imageRendering()); | 2065 return CSSPrimitiveValue::create(style->imageRendering()); |
2062 case CSSPropertyIsolation: | 2066 case CSSPropertyIsolation: |
2063 return cssValuePool().createValue(style->isolation()); | 2067 return cssValuePool().createValue(style->isolation()); |
2064 case CSSPropertyJustifySelf: | 2068 case CSSPropertyJustifyItems: { |
2065 return valueForItemPositionWithOverflowAlignment(style->justifySelf(
), style->justifySelfOverflowAlignment()); | 2069 // FIXME: I would like this to be tested; is not possible with a lay
out test but it |
| 2070 // should be possible using a method similar to https://codereview.c
hromium.org/351973004 |
| 2071 ItemPosition justifyItems = style->justifyItems(); |
| 2072 ItemPositionType positionType = style->justifyItemsPositionType(); |
| 2073 if (justifyItems == ItemPositionAuto) { |
| 2074 Node* parent = styledNode->parentNode(); |
| 2075 // If the inherited value of justify-items includes the legacy k
eyword, 'auto' |
| 2076 // computes to the the inherited value. |
| 2077 if (parent && parent->computedStyle() && parent->computedStyle()
->justifyItemsPositionType()) { |
| 2078 justifyItems = parent->computedStyle()->justifyItems(); |
| 2079 positionType = parent->computedStyle()->justifyItemsPosition
Type(); |
| 2080 // Otherwise, auto computes to: |
| 2081 } else if (style->isDisplayFlexibleOrGridBox()) { |
| 2082 // 'stretch' for flex containers and grid containers. |
| 2083 justifyItems = ItemPositionStretch; |
| 2084 } else { |
| 2085 // 'start' for everything else. |
| 2086 justifyItems = ItemPositionStart; |
| 2087 } |
| 2088 } |
| 2089 return valueForItemPositionWithOverflowAlignment(justifyItems, style
->justifyItemsOverflowAlignment(), positionType); |
| 2090 } |
| 2091 case CSSPropertyJustifySelf: { |
| 2092 // FIXME: I would like this to be tested; is not possible with a lay
out test but it |
| 2093 // should be possible using a method similar to https://codereview.c
hromium.org/351973004 |
| 2094 ItemPosition justifySelf = style->justifySelf(); |
| 2095 if (justifySelf == ItemPositionAuto) { |
| 2096 // The auto keyword computes to stretch on absolutely-positioned
elements, |
| 2097 if (style->position() == AbsolutePosition) { |
| 2098 justifySelf = ItemPositionStretch; |
| 2099 } else { |
| 2100 // and to the computed value of justify-items on the parent
(minus |
| 2101 // any legacy keywords) on all other boxes. |
| 2102 Node* parent = styledNode->parentNode(); |
| 2103 if (parent && parent->computedStyle()) |
| 2104 justifySelf = parent->computedStyle()->justifyItems(); |
| 2105 } |
| 2106 } |
| 2107 return valueForItemPositionWithOverflowAlignment(justifySelf, style-
>justifySelfOverflowAlignment(), NonLegacyPosition); |
| 2108 } |
2066 case CSSPropertyLeft: | 2109 case CSSPropertyLeft: |
2067 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); | 2110 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); |
2068 case CSSPropertyLetterSpacing: | 2111 case CSSPropertyLetterSpacing: |
2069 if (!style->letterSpacing()) | 2112 if (!style->letterSpacing()) |
2070 return cssValuePool().createIdentifierValue(CSSValueNormal); | 2113 return cssValuePool().createIdentifierValue(CSSValueNormal); |
2071 return zoomAdjustedPixelValue(style->letterSpacing(), *style); | 2114 return zoomAdjustedPixelValue(style->letterSpacing(), *style); |
2072 case CSSPropertyWebkitLineClamp: | 2115 case CSSPropertyWebkitLineClamp: |
2073 if (style->lineClamp().isNone()) | 2116 if (style->lineClamp().isNone()) |
2074 return cssValuePool().createIdentifierValue(CSSValueNone); | 2117 return cssValuePool().createIdentifierValue(CSSValueNone); |
2075 return cssValuePool().createValue(style->lineClamp().value(), style-
>lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa
lue::CSS_NUMBER); | 2118 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... |
3090 return list.release(); | 3133 return list.release(); |
3091 } | 3134 } |
3092 | 3135 |
3093 void CSSComputedStyleDeclaration::trace(Visitor* visitor) | 3136 void CSSComputedStyleDeclaration::trace(Visitor* visitor) |
3094 { | 3137 { |
3095 visitor->trace(m_node); | 3138 visitor->trace(m_node); |
3096 CSSStyleDeclaration::trace(visitor); | 3139 CSSStyleDeclaration::trace(visitor); |
3097 } | 3140 } |
3098 | 3141 |
3099 } // namespace WebCore | 3142 } // namespace WebCore |
OLD | NEW |