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 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 { | 1541 { |
1542 if (position != ItemPositionAuto) | 1542 if (position != ItemPositionAuto) |
1543 return position; | 1543 return position; |
1544 | 1544 |
1545 bool isFlexOrGrid = element && element->computedStyle() | 1545 bool isFlexOrGrid = element && element->computedStyle() |
1546 && element->computedStyle()->isDisplayFlexibleOrGridBox(); | 1546 && element->computedStyle()->isDisplayFlexibleOrGridBox(); |
1547 | 1547 |
1548 return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart; | 1548 return isFlexOrGrid ? ItemPositionStretch : ItemPositionStart; |
1549 } | 1549 } |
1550 | 1550 |
| 1551 static void resolveAlignmentContentAuto(RenderStyle& style) |
| 1552 { |
| 1553 if (style.justifyContent() != ContentPositionAuto || style.justifyContentDis
tribution() != ContentDistributionDefault) |
| 1554 return; |
| 1555 |
| 1556 // Block Containers: For table cells, the behavior of the 'auto' depends on
the computed |
| 1557 // value of 'vertical-align', otherwise behaves as 'start'. |
| 1558 // Flex Containers: 'auto' computes to 'stretch'. |
| 1559 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like '
start'. |
| 1560 if (style.isDisplayFlexibleBox()) { |
| 1561 style.setJustifyContent(ContentPositionFlexStart); |
| 1562 } else { |
| 1563 style.setJustifyContent(ContentPositionStart); |
| 1564 } |
| 1565 } |
| 1566 |
1551 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) | 1567 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) |
1552 { | 1568 { |
1553 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 1569 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
1554 if (positionType == LegacyPosition) | 1570 if (positionType == LegacyPosition) |
1555 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 1571 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
1556 result->append(CSSPrimitiveValue::create(itemPosition)); | 1572 result->append(CSSPrimitiveValue::create(itemPosition)); |
1557 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 1573 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) |
1558 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 1574 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
1559 ASSERT(result->length() <= 2); | 1575 ASSERT(result->length() <= 2); |
1560 return result.release(); | 1576 return result.release(); |
1561 } | 1577 } |
1562 | 1578 |
| 1579 static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributi
onWithOverflowAlignment(ContentPosition position, OverflowAlignment overflowAlig
nment, ContentDistributionType distribution) |
| 1580 { |
| 1581 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
| 1582 if (distribution != ContentDistributionDefault) |
| 1583 result->append(CSSPrimitiveValue::create(distribution)); |
| 1584 if (distribution == ContentDistributionDefault || position != ContentPositio
nAuto) |
| 1585 result->append(CSSPrimitiveValue::create(position)); |
| 1586 if ((position >= ContentPositionCenter || distribution != ContentDistributio
nDefault) && overflowAlignment != OverflowAlignmentDefault) |
| 1587 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
| 1588 ASSERT(result->length() > 0); |
| 1589 ASSERT(result->length() <= 3); |
| 1590 return result.release(); |
| 1591 } |
| 1592 |
1563 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const | 1593 PassRefPtrWillBeRawPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValu
e(CSSPropertyID propertyID, EUpdateLayout updateLayout) const |
1564 { | 1594 { |
1565 Node* styledNode = this->styledNode(); | 1595 Node* styledNode = this->styledNode(); |
1566 if (!styledNode) | 1596 if (!styledNode) |
1567 return nullptr; | 1597 return nullptr; |
1568 RenderObject* renderer = styledNode->renderer(); | 1598 RenderObject* renderer = styledNode->renderer(); |
1569 RefPtr<RenderStyle> style; | 1599 RefPtr<RenderStyle> style; |
1570 | 1600 |
1571 if (updateLayout) { | 1601 if (updateLayout) { |
1572 Document& document = styledNode->document(); | 1602 Document& document = styledNode->document(); |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 return cssValuePool().createValue(style->flexDirection()); | 1870 return cssValuePool().createValue(style->flexDirection()); |
1841 case CSSPropertyFlexFlow: | 1871 case CSSPropertyFlexFlow: |
1842 return valuesForShorthandProperty(flexFlowShorthand()); | 1872 return valuesForShorthandProperty(flexFlowShorthand()); |
1843 case CSSPropertyFlexGrow: | 1873 case CSSPropertyFlexGrow: |
1844 return cssValuePool().createValue(style->flexGrow()); | 1874 return cssValuePool().createValue(style->flexGrow()); |
1845 case CSSPropertyFlexShrink: | 1875 case CSSPropertyFlexShrink: |
1846 return cssValuePool().createValue(style->flexShrink()); | 1876 return cssValuePool().createValue(style->flexShrink()); |
1847 case CSSPropertyFlexWrap: | 1877 case CSSPropertyFlexWrap: |
1848 return cssValuePool().createValue(style->flexWrap()); | 1878 return cssValuePool().createValue(style->flexWrap()); |
1849 case CSSPropertyJustifyContent: | 1879 case CSSPropertyJustifyContent: |
1850 return cssValuePool().createValue(style->justifyContent()); | 1880 resolveAlignmentContentAuto(*style); |
| 1881 return valueForContentPositionAndDistributionWithOverflowAlignment(s
tyle->justifyContent(), style->justifyContentOverflowAlignment(), style->justify
ContentDistribution()); |
1851 case CSSPropertyOrder: | 1882 case CSSPropertyOrder: |
1852 return cssValuePool().createValue(style->order(), CSSPrimitiveValue:
:CSS_NUMBER); | 1883 return cssValuePool().createValue(style->order(), CSSPrimitiveValue:
:CSS_NUMBER); |
1853 case CSSPropertyFloat: | 1884 case CSSPropertyFloat: |
1854 if (style->display() != NONE && style->hasOutOfFlowPosition()) | 1885 if (style->display() != NONE && style->hasOutOfFlowPosition()) |
1855 return cssValuePool().createIdentifierValue(CSSValueNone); | 1886 return cssValuePool().createIdentifierValue(CSSValueNone); |
1856 return cssValuePool().createValue(style->floating()); | 1887 return cssValuePool().createValue(style->floating()); |
1857 case CSSPropertyFont: { | 1888 case CSSPropertyFont: { |
1858 RefPtrWillBeRawPtr<CSSFontValue> computedFont = CSSFontValue::create
(); | 1889 RefPtrWillBeRawPtr<CSSFontValue> computedFont = CSSFontValue::create
(); |
1859 computedFont->style = valueForFontStyle(*style); | 1890 computedFont->style = valueForFontStyle(*style); |
1860 computedFont->variant = valueForFontVariant(*style); | 1891 computedFont->variant = valueForFontVariant(*style); |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 return list.release(); | 3034 return list.release(); |
3004 } | 3035 } |
3005 | 3036 |
3006 void CSSComputedStyleDeclaration::trace(Visitor* visitor) | 3037 void CSSComputedStyleDeclaration::trace(Visitor* visitor) |
3007 { | 3038 { |
3008 visitor->trace(m_node); | 3039 visitor->trace(m_node); |
3009 CSSStyleDeclaration::trace(visitor); | 3040 CSSStyleDeclaration::trace(visitor); |
3010 } | 3041 } |
3011 | 3042 |
3012 } // namespace blink | 3043 } // namespace blink |
OLD | NEW |