| 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 * Copyright (C) 2015 Google Inc. All rights reserved. | 7 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Lesser General Public | 10 * modify it under the terms of the GNU Lesser General Public |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 direction = cssValuePool().createIdentifierValue(CSSValueLeft); | 375 direction = cssValuePool().createIdentifierValue(CSSValueLeft); |
| 376 break; | 376 break; |
| 377 case ReflectionRight: | 377 case ReflectionRight: |
| 378 direction = cssValuePool().createIdentifierValue(CSSValueRight); | 378 direction = cssValuePool().createIdentifierValue(CSSValueRight); |
| 379 break; | 379 break; |
| 380 } | 380 } |
| 381 | 381 |
| 382 return CSSReflectValue::create(direction.release(), offset.release(), valueF
orNinePieceImage(reflection->mask(), style)); | 382 return CSSReflectValue::create(direction.release(), offset.release(), valueF
orNinePieceImage(reflection->mask(), style)); |
| 383 } | 383 } |
| 384 | 384 |
| 385 static ItemPosition resolveAlignmentAuto(ItemPosition position, Node* element) | 385 static ItemPosition resolveContainerAlignmentAuto(ItemPosition position, const L
ayoutObject* element) |
| 386 { | 386 { |
| 387 if (position != ItemPositionAuto) | 387 if (position != ItemPositionAuto || !element) |
| 388 return position; | 388 return position; |
| 389 | 389 |
| 390 return isFlexOrGrid(element) ? ItemPositionStretch : ItemPositionStart; | 390 LayoutBlock* container = element->containingBlock(); |
| 391 if (container && container->style()->justifyItemsPositionType() == LegacyPos
ition) |
| 392 return container->style()->justifyItemsPosition(); |
| 393 |
| 394 return element->style()->isDisplayFlexibleOrGridBox() ? ItemPositionStretch
: ItemPositionStart; |
| 395 } |
| 396 |
| 397 static ItemPosition resolveSelfAlignmentAuto(ItemPosition position, OverflowAlig
nment& overflow, const LayoutObject* element) |
| 398 { |
| 399 if (position != ItemPositionAuto || !element || element->isOutOfFlowPosition
ed()) |
| 400 return position; |
| 401 |
| 402 LayoutBlock* parent = element->containingBlock(); |
| 403 if (!parent) |
| 404 return ItemPositionStart; |
| 405 |
| 406 overflow = parent->style()->alignItemsOverflowAlignment(); |
| 407 return resolveContainerAlignmentAuto(parent->style()->alignItemsPosition(),
parent); |
| 408 } |
| 409 |
| 410 static void resolveContentAlignmentAuto(ContentPosition& position, ContentDistri
butionType& distribution, const LayoutObject* element) |
| 411 { |
| 412 if (position != ContentPositionAuto || distribution != ContentDistributionDe
fault) |
| 413 return; |
| 414 |
| 415 if (element && element->style()->isDisplayFlexibleBox()) |
| 416 distribution = ContentDistributionStretch; |
| 417 else |
| 418 position = ContentPositionStart; |
| 391 } | 419 } |
| 392 | 420 |
| 393 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) | 421 static PassRefPtrWillBeRawPtr<CSSValueList> valueForItemPositionWithOverflowAlig
nment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositi
onType positionType) |
| 394 { | 422 { |
| 395 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 423 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
| 396 if (positionType == LegacyPosition) | 424 if (positionType == LegacyPosition) |
| 397 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 425 result->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
| 398 result->append(CSSPrimitiveValue::create(itemPosition)); | 426 result->append(CSSPrimitiveValue::create(itemPosition)); |
| 399 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 427 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) |
| 400 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 428 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceS
eparated(); | 472 RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceS
eparated(); |
| 445 afterSlash->append(valueForFillSize(currLayer->size(), style)); | 473 afterSlash->append(valueForFillSize(currLayer->size(), style)); |
| 446 afterSlash->append(cssValuePool().createValue(currLayer->origin())); | 474 afterSlash->append(cssValuePool().createValue(currLayer->origin())); |
| 447 afterSlash->append(cssValuePool().createValue(currLayer->clip())); | 475 afterSlash->append(cssValuePool().createValue(currLayer->clip())); |
| 448 list->append(afterSlash); | 476 list->append(afterSlash); |
| 449 ret->append(list); | 477 ret->append(list); |
| 450 } | 478 } |
| 451 return ret.release(); | 479 return ret.release(); |
| 452 } | 480 } |
| 453 | 481 |
| 454 static ContentPosition resolveContentAlignmentAuto(ContentPosition position, Con
tentDistributionType distribution, Node* element) | |
| 455 { | |
| 456 if (position != ContentPositionAuto || distribution != ContentDistributionDe
fault) | |
| 457 return position; | |
| 458 | |
| 459 bool isFlex = element && element->ensureComputedStyle() | |
| 460 && element->ensureComputedStyle()->isDisplayFlexibleBox(); | |
| 461 | |
| 462 return isFlex ? ContentPositionFlexStart : ContentPositionStart; | |
| 463 } | |
| 464 | |
| 465 static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributi
onWithOverflowAlignment(ContentPosition position, OverflowAlignment overflowAlig
nment, ContentDistributionType distribution) | 482 static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributi
onWithOverflowAlignment(ContentPosition position, OverflowAlignment overflowAlig
nment, ContentDistributionType distribution) |
| 466 { | 483 { |
| 467 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); | 484 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated
(); |
| 468 if (distribution != ContentDistributionDefault) | 485 if (distribution != ContentDistributionDefault) |
| 469 result->append(CSSPrimitiveValue::create(distribution)); | 486 result->append(CSSPrimitiveValue::create(distribution)); |
| 470 if (distribution == ContentDistributionDefault || position != ContentPositio
nAuto) | 487 if (distribution == ContentDistributionDefault || position != ContentPositio
nAuto) |
| 471 result->append(CSSPrimitiveValue::create(position)); | 488 result->append(CSSPrimitiveValue::create(position)); |
| 472 if ((position >= ContentPositionCenter || distribution != ContentDistributio
nDefault) && overflowAlignment != OverflowAlignmentDefault) | 489 if ((position >= ContentPositionCenter || distribution != ContentDistributio
nDefault) && overflowAlignment != OverflowAlignmentDefault) |
| 473 result->append(CSSPrimitiveValue::create(overflowAlignment)); | 490 result->append(CSSPrimitiveValue::create(overflowAlignment)); |
| 474 ASSERT(result->length() > 0); | 491 ASSERT(result->length() > 0); |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 return list.release(); | 1563 return list.release(); |
| 1547 } | 1564 } |
| 1548 return value.release(); | 1565 return value.release(); |
| 1549 } | 1566 } |
| 1550 case CSSPropertyDirection: | 1567 case CSSPropertyDirection: |
| 1551 return cssValuePool().createValue(style.direction()); | 1568 return cssValuePool().createValue(style.direction()); |
| 1552 case CSSPropertyDisplay: | 1569 case CSSPropertyDisplay: |
| 1553 return cssValuePool().createValue(style.display()); | 1570 return cssValuePool().createValue(style.display()); |
| 1554 case CSSPropertyEmptyCells: | 1571 case CSSPropertyEmptyCells: |
| 1555 return cssValuePool().createValue(style.emptyCells()); | 1572 return cssValuePool().createValue(style.emptyCells()); |
| 1556 case CSSPropertyAlignContent: | 1573 case CSSPropertyAlignContent: { |
| 1557 return valueForContentPositionAndDistributionWithOverflowAlignment(resol
veContentAlignmentAuto(style.alignContentPosition(), style.alignContentDistribut
ion(), styledNode), style.alignContentOverflowAlignment(), style.alignContentDis
tribution()); | 1574 ContentPosition position = style.alignContentPosition(); |
| 1575 ContentDistributionType distribution = style.alignContentDistribution(); |
| 1576 resolveContentAlignmentAuto(position, distribution, layoutObject); |
| 1577 return valueForContentPositionAndDistributionWithOverflowAlignment(posit
ion, style.alignContentOverflowAlignment(), distribution); |
| 1578 } |
| 1558 case CSSPropertyAlignItems: | 1579 case CSSPropertyAlignItems: |
| 1559 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.alignItemsPosition(), styledNode), style.alignItemsOverflowAlignment(), NonL
egacyPosition); | 1580 return valueForItemPositionWithOverflowAlignment(resolveContainerAlignme
ntAuto(style.alignItemsPosition(), layoutObject), style.alignItemsOverflowAlignm
ent(), NonLegacyPosition); |
| 1560 case CSSPropertyAlignSelf: | 1581 case CSSPropertyAlignSelf: { |
| 1561 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.alignSelfPosition(), styledNode->parentNode()), style.alignSelfOverflowAlign
ment(), NonLegacyPosition); | 1582 OverflowAlignment overflow = style.alignSelfOverflowAlignment(); |
| 1583 ItemPosition alignSelf = resolveSelfAlignmentAuto(style.alignSelfPositio
n(), overflow, layoutObject); |
| 1584 return valueForItemPositionWithOverflowAlignment(alignSelf, overflow, No
nLegacyPosition); |
| 1585 } |
| 1562 case CSSPropertyFlex: | 1586 case CSSPropertyFlex: |
| 1563 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); | 1587 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); |
| 1564 case CSSPropertyFlexBasis: | 1588 case CSSPropertyFlexBasis: |
| 1565 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); | 1589 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); |
| 1566 case CSSPropertyFlexDirection: | 1590 case CSSPropertyFlexDirection: |
| 1567 return cssValuePool().createValue(style.flexDirection()); | 1591 return cssValuePool().createValue(style.flexDirection()); |
| 1568 case CSSPropertyFlexFlow: | 1592 case CSSPropertyFlexFlow: |
| 1569 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); | 1593 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); |
| 1570 case CSSPropertyFlexGrow: | 1594 case CSSPropertyFlexGrow: |
| 1571 return cssValuePool().createValue(style.flexGrow()); | 1595 return cssValuePool().createValue(style.flexGrow()); |
| 1572 case CSSPropertyFlexShrink: | 1596 case CSSPropertyFlexShrink: |
| 1573 return cssValuePool().createValue(style.flexShrink()); | 1597 return cssValuePool().createValue(style.flexShrink()); |
| 1574 case CSSPropertyFlexWrap: | 1598 case CSSPropertyFlexWrap: |
| 1575 return cssValuePool().createValue(style.flexWrap()); | 1599 return cssValuePool().createValue(style.flexWrap()); |
| 1576 case CSSPropertyJustifyContent: | 1600 case CSSPropertyJustifyContent: { |
| 1577 return valueForContentPositionAndDistributionWithOverflowAlignment(resol
veContentAlignmentAuto(style.justifyContentPosition(), style.justifyContentDistr
ibution(), styledNode), style.justifyContentOverflowAlignment(), style.justifyCo
ntentDistribution()); | 1601 ContentPosition position = style.justifyContentPosition(); |
| 1602 ContentDistributionType distribution = style.justifyContentDistribution(
); |
| 1603 resolveContentAlignmentAuto(position, distribution, layoutObject); |
| 1604 return valueForContentPositionAndDistributionWithOverflowAlignment(posit
ion, style.justifyContentOverflowAlignment(), distribution); |
| 1605 } |
| 1578 case CSSPropertyOrder: | 1606 case CSSPropertyOrder: |
| 1579 return cssValuePool().createValue(style.order(), CSSPrimitiveValue::CSS_
NUMBER); | 1607 return cssValuePool().createValue(style.order(), CSSPrimitiveValue::CSS_
NUMBER); |
| 1580 case CSSPropertyFloat: | 1608 case CSSPropertyFloat: |
| 1581 if (style.display() != NONE && style.hasOutOfFlowPosition()) | 1609 if (style.display() != NONE && style.hasOutOfFlowPosition()) |
| 1582 return cssValuePool().createIdentifierValue(CSSValueNone); | 1610 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 1583 return cssValuePool().createValue(style.floating()); | 1611 return cssValuePool().createValue(style.floating()); |
| 1584 case CSSPropertyFont: { | 1612 case CSSPropertyFont: { |
| 1585 RefPtrWillBeRawPtr<CSSFontValue> computedFont = CSSFontValue::create(); | 1613 RefPtrWillBeRawPtr<CSSFontValue> computedFont = CSSFontValue::create(); |
| 1586 computedFont->style = valueForFontStyle(style); | 1614 computedFont->style = valueForFontStyle(style); |
| 1587 computedFont->variant = valueForFontVariant(style); | 1615 computedFont->variant = valueForFontVariant(style); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1703 return cssValuePool().createValue(style.highlight(), CSSPrimitiveValue::
CSS_STRING); | 1731 return cssValuePool().createValue(style.highlight(), CSSPrimitiveValue::
CSS_STRING); |
| 1704 case CSSPropertyWebkitHyphenateCharacter: | 1732 case CSSPropertyWebkitHyphenateCharacter: |
| 1705 if (style.hyphenationString().isNull()) | 1733 if (style.hyphenationString().isNull()) |
| 1706 return cssValuePool().createIdentifierValue(CSSValueAuto); | 1734 return cssValuePool().createIdentifierValue(CSSValueAuto); |
| 1707 return cssValuePool().createValue(style.hyphenationString(), CSSPrimitiv
eValue::CSS_STRING); | 1735 return cssValuePool().createValue(style.hyphenationString(), CSSPrimitiv
eValue::CSS_STRING); |
| 1708 case CSSPropertyImageRendering: | 1736 case CSSPropertyImageRendering: |
| 1709 return CSSPrimitiveValue::create(style.imageRendering()); | 1737 return CSSPrimitiveValue::create(style.imageRendering()); |
| 1710 case CSSPropertyIsolation: | 1738 case CSSPropertyIsolation: |
| 1711 return cssValuePool().createValue(style.isolation()); | 1739 return cssValuePool().createValue(style.isolation()); |
| 1712 case CSSPropertyJustifyItems: | 1740 case CSSPropertyJustifyItems: |
| 1713 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifyItemsPosition(), styledNode), style.justifyItemsOverflowAlignment(),
style.justifyItemsPositionType()); | 1741 return valueForItemPositionWithOverflowAlignment(resolveContainerAlignme
ntAuto(style.justifyItemsPosition(), layoutObject), style.justifyItemsOverflowAl
ignment(), style.justifyItemsPositionType()); |
| 1714 case CSSPropertyJustifySelf: | 1742 case CSSPropertyJustifySelf: { |
| 1715 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifySelfPosition(), styledNode->parentNode()), style.justifySelfOverflowA
lignment(), NonLegacyPosition); | 1743 OverflowAlignment overflow = style.justifySelfOverflowAlignment(); |
| 1744 ItemPosition justifySelf = resolveSelfAlignmentAuto(style.justifySelfPos
ition(), overflow, layoutObject); |
| 1745 return valueForItemPositionWithOverflowAlignment(justifySelf, overflow,
NonLegacyPosition); |
| 1746 } |
| 1716 case CSSPropertyLeft: | 1747 case CSSPropertyLeft: |
| 1717 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); | 1748 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); |
| 1718 case CSSPropertyLetterSpacing: | 1749 case CSSPropertyLetterSpacing: |
| 1719 if (!style.letterSpacing()) | 1750 if (!style.letterSpacing()) |
| 1720 return cssValuePool().createIdentifierValue(CSSValueNormal); | 1751 return cssValuePool().createIdentifierValue(CSSValueNormal); |
| 1721 return zoomAdjustedPixelValue(style.letterSpacing(), style); | 1752 return zoomAdjustedPixelValue(style.letterSpacing(), style); |
| 1722 case CSSPropertyWebkitLineClamp: | 1753 case CSSPropertyWebkitLineClamp: |
| 1723 if (style.lineClamp().isNone()) | 1754 if (style.lineClamp().isNone()) |
| 1724 return cssValuePool().createIdentifierValue(CSSValueNone); | 1755 return cssValuePool().createIdentifierValue(CSSValueNone); |
| 1725 return cssValuePool().createValue(style.lineClamp().value(), style.lineC
lamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::C
SS_NUMBER); | 1756 return cssValuePool().createValue(style.lineClamp().value(), style.lineC
lamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::C
SS_NUMBER); |
| (...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2588 case CSSPropertyAll: | 2619 case CSSPropertyAll: |
| 2589 return nullptr; | 2620 return nullptr; |
| 2590 default: | 2621 default: |
| 2591 break; | 2622 break; |
| 2592 } | 2623 } |
| 2593 ASSERT_NOT_REACHED(); | 2624 ASSERT_NOT_REACHED(); |
| 2594 return nullptr; | 2625 return nullptr; |
| 2595 } | 2626 } |
| 2596 | 2627 |
| 2597 } | 2628 } |
| OLD | NEW |