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 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi onType positionType) | 1559 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi onType positionType) |
1560 { | 1560 { |
1561 ItemPosition resolvedPosition = itemPosition == ItemPositionAuto ? ItemPosit ionStart : itemPosition; | |
svillar
2014/07/29 10:40:05
Maybe we need some ASSERT here? I guess you're ass
| |
1561 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); | 1562 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); |
1562 if (positionType == LegacyPosition) | 1563 if (positionType == LegacyPosition) |
1563 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 1564 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
1564 result->append(CSSPrimitiveValue::create(itemPosition)); | 1565 result->append(CSSPrimitiveValue::create(resolvedPosition)); |
1565 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign mentDefault) | 1566 if (resolvedPosition >= ItemPositionCenter && overflowAlignment != OverflowA lignmentDefault) |
1566 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 1567 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
1567 ASSERT(result->length() <= 2); | 1568 ASSERT(result->length() <= 2); |
1568 return result.release(); | 1569 return result.release(); |
1569 } | 1570 } |
1570 | 1571 |
1571 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const | 1572 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const |
1572 { | 1573 { |
1573 Node* styledNode = this->styledNode(); | 1574 Node* styledNode = this->styledNode(); |
1574 if (!styledNode) | 1575 if (!styledNode) |
1575 return nullptr; | 1576 return nullptr; |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1880 case CSSPropertyDirection: | 1881 case CSSPropertyDirection: |
1881 return cssValuePool().createValue(style->direction()); | 1882 return cssValuePool().createValue(style->direction()); |
1882 case CSSPropertyDisplay: | 1883 case CSSPropertyDisplay: |
1883 return cssValuePool().createValue(style->display()); | 1884 return cssValuePool().createValue(style->display()); |
1884 case CSSPropertyEmptyCells: | 1885 case CSSPropertyEmptyCells: |
1885 return cssValuePool().createValue(style->emptyCells()); | 1886 return cssValuePool().createValue(style->emptyCells()); |
1886 case CSSPropertyAlignContent: | 1887 case CSSPropertyAlignContent: |
1887 return cssValuePool().createValue(style->alignContent()); | 1888 return cssValuePool().createValue(style->alignContent()); |
1888 case CSSPropertyAlignItems: | 1889 case CSSPropertyAlignItems: |
1889 return valueForItemPositionWithOverflowAlignment(style->alignItems() , style->alignItemsOverflowAlignment(), NonLegacyPosition); | 1890 return valueForItemPositionWithOverflowAlignment(style->alignItems() , style->alignItemsOverflowAlignment(), NonLegacyPosition); |
1890 case CSSPropertyAlignSelf: { | 1891 case CSSPropertyAlignSelf: |
1891 ItemPosition alignSelf = style->alignSelf(); | 1892 return valueForItemPositionWithOverflowAlignment(style->alignSelf(), style->alignSelfOverflowAlignment(), 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: | 1893 case CSSPropertyFlex: |
1902 return valuesForShorthandProperty(flexShorthand()); | 1894 return valuesForShorthandProperty(flexShorthand()); |
1903 case CSSPropertyFlexBasis: | 1895 case CSSPropertyFlexBasis: |
1904 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); | 1896 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); |
1905 case CSSPropertyFlexDirection: | 1897 case CSSPropertyFlexDirection: |
1906 return cssValuePool().createValue(style->flexDirection()); | 1898 return cssValuePool().createValue(style->flexDirection()); |
1907 case CSSPropertyFlexFlow: | 1899 case CSSPropertyFlexFlow: |
1908 return valuesForShorthandProperty(flexFlowShorthand()); | 1900 return valuesForShorthandProperty(flexFlowShorthand()); |
1909 case CSSPropertyFlexGrow: | 1901 case CSSPropertyFlexGrow: |
1910 return cssValuePool().createValue(style->flexGrow()); | 1902 return cssValuePool().createValue(style->flexGrow()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2054 return cssValuePool().createIdentifierValue(CSSValueAuto); | 2046 return cssValuePool().createIdentifierValue(CSSValueAuto); |
2055 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); | 2047 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); |
2056 case CSSPropertyWebkitBorderFit: | 2048 case CSSPropertyWebkitBorderFit: |
2057 if (style->borderFit() == BorderFitBorder) | 2049 if (style->borderFit() == BorderFitBorder) |
2058 return cssValuePool().createIdentifierValue(CSSValueBorder); | 2050 return cssValuePool().createIdentifierValue(CSSValueBorder); |
2059 return cssValuePool().createIdentifierValue(CSSValueLines); | 2051 return cssValuePool().createIdentifierValue(CSSValueLines); |
2060 case CSSPropertyImageRendering: | 2052 case CSSPropertyImageRendering: |
2061 return CSSPrimitiveValue::create(style->imageRendering()); | 2053 return CSSPrimitiveValue::create(style->imageRendering()); |
2062 case CSSPropertyIsolation: | 2054 case CSSPropertyIsolation: |
2063 return cssValuePool().createValue(style->isolation()); | 2055 return cssValuePool().createValue(style->isolation()); |
2064 case CSSPropertyJustifyItems: { | 2056 case CSSPropertyJustifyItems: |
2065 // FIXME: I would like this to be tested; is not possible with a lay out test but it | 2057 return valueForItemPositionWithOverflowAlignment(style->justifyItems (), style->justifyItemsOverflowAlignment(), style->justifyItemsPositionType()); |
2066 // should be possible using a method similar to https://codereview.c hromium.org/351973004 | 2058 case CSSPropertyJustifySelf: |
2067 ItemPosition justifyItems = style->justifyItems(); | 2059 return valueForItemPositionWithOverflowAlignment(style->justifySelf( ), style->justifySelfOverflowAlignment(), 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: | 2060 case CSSPropertyLeft: |
2106 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); | 2061 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); |
2107 case CSSPropertyLetterSpacing: | 2062 case CSSPropertyLetterSpacing: |
2108 if (!style->letterSpacing()) | 2063 if (!style->letterSpacing()) |
2109 return cssValuePool().createIdentifierValue(CSSValueNormal); | 2064 return cssValuePool().createIdentifierValue(CSSValueNormal); |
2110 return zoomAdjustedPixelValue(style->letterSpacing(), *style); | 2065 return zoomAdjustedPixelValue(style->letterSpacing(), *style); |
2111 case CSSPropertyWebkitLineClamp: | 2066 case CSSPropertyWebkitLineClamp: |
2112 if (style->lineClamp().isNone()) | 2067 if (style->lineClamp().isNone()) |
2113 return cssValuePool().createIdentifierValue(CSSValueNone); | 2068 return cssValuePool().createIdentifierValue(CSSValueNone); |
2114 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER); | 2069 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(); | 3084 return list.release(); |
3130 } | 3085 } |
3131 | 3086 |
3132 void CSSComputedStyleDeclaration::trace(Visitor* visitor) | 3087 void CSSComputedStyleDeclaration::trace(Visitor* visitor) |
3133 { | 3088 { |
3134 visitor->trace(m_node); | 3089 visitor->trace(m_node); |
3135 CSSStyleDeclaration::trace(visitor); | 3090 CSSStyleDeclaration::trace(visitor); |
3136 } | 3091 } |
3137 | 3092 |
3138 } // namespace blink | 3093 } // namespace blink |
OLD | NEW |