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, bool isLeg acy) |
Julien - ping for review
2014/06/24 19:04:56
PLEASE NO BOOLEAN PARAMETERS!
You can either add
jfernandez
2014/06/26 12:58:44
I finally implemented an enumeration.
| |
1558 { | 1559 { |
1559 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); | 1560 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); |
1561 if (isLegacy) | |
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)); |
Julien - ping for review
2014/06/24 19:04:56
ASSERT(result.size() <= 2); as you make the assump
jfernandez
2014/06/26 12:58:44
"result->length() <= 2", instead, but I've got the
| |
1563 return result.release(); | 1566 return result.release(); |
1564 } | 1567 } |
1565 | 1568 |
1569 static bool isDisplayFlexibleOrGridBox(EDisplay display) | |
1570 { | |
1571 return display == FLEX || display == INLINE_FLEX || display == GRID || displ ay == INLINE_GRID; | |
Julien - ping for review
2014/06/24 19:04:56
RenderStyle has some similar checks, maybe we coul
jfernandez
2014/06/26 12:58:44
I've finally implemented a new method "isDisplayFl
| |
1572 } | |
1573 | |
1566 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const | 1574 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const |
1567 { | 1575 { |
1568 Node* styledNode = this->styledNode(); | 1576 Node* styledNode = this->styledNode(); |
1569 if (!styledNode) | 1577 if (!styledNode) |
1570 return nullptr; | 1578 return nullptr; |
1571 RenderObject* renderer = styledNode->renderer(); | 1579 RenderObject* renderer = styledNode->renderer(); |
1572 RefPtr<RenderStyle> style; | 1580 RefPtr<RenderStyle> style; |
1573 | 1581 |
1574 if (updateLayout) { | 1582 if (updateLayout) { |
1575 Document& document = styledNode->document(); | 1583 Document& document = styledNode->document(); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1879 } | 1887 } |
1880 case CSSPropertyDirection: | 1888 case CSSPropertyDirection: |
1881 return cssValuePool().createValue(style->direction()); | 1889 return cssValuePool().createValue(style->direction()); |
1882 case CSSPropertyDisplay: | 1890 case CSSPropertyDisplay: |
1883 return cssValuePool().createValue(style->display()); | 1891 return cssValuePool().createValue(style->display()); |
1884 case CSSPropertyEmptyCells: | 1892 case CSSPropertyEmptyCells: |
1885 return cssValuePool().createValue(style->emptyCells()); | 1893 return cssValuePool().createValue(style->emptyCells()); |
1886 case CSSPropertyAlignContent: | 1894 case CSSPropertyAlignContent: |
1887 return cssValuePool().createValue(style->alignContent()); | 1895 return cssValuePool().createValue(style->alignContent()); |
1888 case CSSPropertyAlignItems: | 1896 case CSSPropertyAlignItems: |
1889 return valueForItemPositionWithOverflowAlignment(style->alignItems() , style->alignItemsOverflowAlignment()); | 1897 return valueForItemPositionWithOverflowAlignment(style->alignItems() , style->alignItemsOverflowAlignment(), false); |
1890 case CSSPropertyAlignSelf: { | 1898 case CSSPropertyAlignSelf: { |
1891 ItemPosition alignSelf = style->alignSelf(); | 1899 ItemPosition alignSelf = style->alignSelf(); |
1892 if (alignSelf == ItemPositionAuto) { | 1900 if (alignSelf == ItemPositionAuto) { |
1893 Node* parent = styledNode->parentNode(); | 1901 Node* parent = styledNode->parentNode(); |
1894 if (parent && parent->computedStyle()) | 1902 if (parent && parent->computedStyle()) |
1895 alignSelf = parent->computedStyle()->alignItems(); | 1903 alignSelf = parent->computedStyle()->alignItems(); |
1896 else | 1904 else |
1897 alignSelf = ItemPositionStretch; | 1905 alignSelf = ItemPositionStretch; |
1898 } | 1906 } |
1899 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a lignSelfOverflowAlignment()); | 1907 return valueForItemPositionWithOverflowAlignment(alignSelf, style->a lignSelfOverflowAlignment(), false); |
1900 } | 1908 } |
1901 case CSSPropertyFlex: | 1909 case CSSPropertyFlex: |
1902 return valuesForShorthandProperty(flexShorthand()); | 1910 return valuesForShorthandProperty(flexShorthand()); |
1903 case CSSPropertyFlexBasis: | 1911 case CSSPropertyFlexBasis: |
1904 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); | 1912 return zoomAdjustedPixelValueForLength(style->flexBasis(), *style); |
1905 case CSSPropertyFlexDirection: | 1913 case CSSPropertyFlexDirection: |
1906 return cssValuePool().createValue(style->flexDirection()); | 1914 return cssValuePool().createValue(style->flexDirection()); |
1907 case CSSPropertyFlexFlow: | 1915 case CSSPropertyFlexFlow: |
1908 return valuesForShorthandProperty(flexFlowShorthand()); | 1916 return valuesForShorthandProperty(flexFlowShorthand()); |
1909 case CSSPropertyFlexGrow: | 1917 case CSSPropertyFlexGrow: |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2020 return cssValuePool().createIdentifierValue(CSSValueAuto); | 2028 return cssValuePool().createIdentifierValue(CSSValueAuto); |
2021 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); | 2029 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); |
2022 case CSSPropertyWebkitBorderFit: | 2030 case CSSPropertyWebkitBorderFit: |
2023 if (style->borderFit() == BorderFitBorder) | 2031 if (style->borderFit() == BorderFitBorder) |
2024 return cssValuePool().createIdentifierValue(CSSValueBorder); | 2032 return cssValuePool().createIdentifierValue(CSSValueBorder); |
2025 return cssValuePool().createIdentifierValue(CSSValueLines); | 2033 return cssValuePool().createIdentifierValue(CSSValueLines); |
2026 case CSSPropertyImageRendering: | 2034 case CSSPropertyImageRendering: |
2027 return CSSPrimitiveValue::create(style->imageRendering()); | 2035 return CSSPrimitiveValue::create(style->imageRendering()); |
2028 case CSSPropertyIsolation: | 2036 case CSSPropertyIsolation: |
2029 return cssValuePool().createValue(style->isolation()); | 2037 return cssValuePool().createValue(style->isolation()); |
2030 case CSSPropertyJustifySelf: | 2038 case CSSPropertyJustifyItems: { |
2031 return valueForItemPositionWithOverflowAlignment(style->justifySelf( ), style->justifySelfOverflowAlignment()); | 2039 ItemPosition justifyItems = style->justifyItems(); |
2040 bool isLegacy = style->justifyItemsIsLegacy(); | |
2041 if (justifyItems == ItemPositionAuto) { | |
2042 Node* parent = styledNode->parentNode(); | |
2043 // If the inherited value of justify-items includes the legacy k eyword, 'auto' | |
2044 // computes to the the inherited value. | |
2045 if (parent && parent->computedStyle() && parent->computedStyle() ->justifyItemsIsLegacy()) { | |
2046 justifyItems = parent->computedStyle()->justifyItems(); | |
2047 isLegacy = parent->computedStyle()->justifyItemsIsLegacy(); | |
2048 // Otherwise, auto computes to: | |
2049 } else if (isDisplayFlexibleOrGridBox(style->display())) { | |
2050 // 'stretch' for flex containers and grid containers. | |
2051 justifyItems = ItemPositionStretch; | |
2052 } else { | |
2053 // 'start' for everything else. | |
2054 justifyItems = ItemPositionStart; | |
2055 } | |
2056 } | |
2057 return valueForItemPositionWithOverflowAlignment(justifyItems, style ->justifyItemsOverflowAlignment(), isLegacy); | |
2058 } | |
2059 case CSSPropertyJustifySelf: { | |
2060 ItemPosition justifySelf = style->justifySelf(); | |
2061 if (justifySelf == ItemPositionAuto) { | |
2062 // The auto keyword computes to stretch on absolutely-positioned elements, | |
2063 if (style->position() == AbsolutePosition) { | |
2064 justifySelf = ItemPositionStretch; | |
2065 } else { | |
2066 // and to the computed value of justify-items on the parent (minus | |
2067 // any legacy keywords) on all other boxes. | |
2068 Node* parent = styledNode->parentNode(); | |
2069 if (parent && parent->computedStyle()) | |
2070 justifySelf = parent->computedStyle()->justifyItems(); | |
2071 } | |
2072 } | |
2073 return valueForItemPositionWithOverflowAlignment(justifySelf, style- >justifySelfOverflowAlignment(), false); | |
2074 } | |
2032 case CSSPropertyLeft: | 2075 case CSSPropertyLeft: |
2033 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); | 2076 return valueForPositionOffset(*style, CSSPropertyLeft, renderer); |
2034 case CSSPropertyLetterSpacing: | 2077 case CSSPropertyLetterSpacing: |
2035 if (!style->letterSpacing()) | 2078 if (!style->letterSpacing()) |
2036 return cssValuePool().createIdentifierValue(CSSValueNormal); | 2079 return cssValuePool().createIdentifierValue(CSSValueNormal); |
2037 return zoomAdjustedPixelValue(style->letterSpacing(), *style); | 2080 return zoomAdjustedPixelValue(style->letterSpacing(), *style); |
2038 case CSSPropertyWebkitLineClamp: | 2081 case CSSPropertyWebkitLineClamp: |
2039 if (style->lineClamp().isNone()) | 2082 if (style->lineClamp().isNone()) |
2040 return cssValuePool().createIdentifierValue(CSSValueNone); | 2083 return cssValuePool().createIdentifierValue(CSSValueNone); |
2041 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER); | 2084 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER); |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3057 return list.release(); | 3100 return list.release(); |
3058 } | 3101 } |
3059 | 3102 |
3060 void CSSComputedStyleDeclaration::trace(Visitor* visitor) | 3103 void CSSComputedStyleDeclaration::trace(Visitor* visitor) |
3061 { | 3104 { |
3062 visitor->trace(m_node); | 3105 visitor->trace(m_node); |
3063 CSSStyleDeclaration::trace(visitor); | 3106 CSSStyleDeclaration::trace(visitor); |
3064 } | 3107 } |
3065 | 3108 |
3066 } // namespace WebCore | 3109 } // namespace WebCore |
OLD | NEW |