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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 direction = CSSPrimitiveValue::createIdentifier(CSSValueLeft); | 434 direction = CSSPrimitiveValue::createIdentifier(CSSValueLeft); |
435 break; | 435 break; |
436 case ReflectionRight: | 436 case ReflectionRight: |
437 direction = CSSPrimitiveValue::createIdentifier(CSSValueRight); | 437 direction = CSSPrimitiveValue::createIdentifier(CSSValueRight); |
438 break; | 438 break; |
439 } | 439 } |
440 | 440 |
441 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref
lection->mask(), style)); | 441 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref
lection->mask(), style)); |
442 } | 442 } |
443 | 443 |
444 static ItemPosition resolveAlignmentAuto(ItemPosition position, const ComputedSt
yle* style) | 444 static CSSValueList* valueForItemPositionWithOverflowAlignment(const StyleSelfAl
ignmentData& data) |
445 { | |
446 if (position != ItemPositionAuto) | |
447 return position; | |
448 | |
449 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | |
450 return ItemPositionStretch; | |
451 | |
452 return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart; | |
453 } | |
454 | |
455 static CSSValueList* valueForItemPositionWithOverflowAlignment(ItemPosition item
Position, OverflowAlignment overflowAlignment, ItemPositionType positionType) | |
456 { | 445 { |
457 CSSValueList* result = CSSValueList::createSpaceSeparated(); | 446 CSSValueList* result = CSSValueList::createSpaceSeparated(); |
458 if (positionType == LegacyPosition) | 447 if (data.positionType() == LegacyPosition) |
459 result->append(*CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 448 result->append(*CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
460 result->append(*CSSPrimitiveValue::create(itemPosition)); | 449 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto
' flag to not just mean 'auto' prior to running the StyleAdjuster but also mean
'normal' after running it. |
461 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 450 result->append(*CSSPrimitiveValue::create(data.position() == ItemPositionAut
o ? ItemPositionNormal : data.position())); |
462 result->append(*CSSPrimitiveValue::create(overflowAlignment)); | 451 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig
nmentDefault) |
| 452 result->append(*CSSPrimitiveValue::create(data.overflow())); |
463 ASSERT(result->length() <= 2); | 453 ASSERT(result->length() <= 2); |
464 return result; | 454 return result; |
465 } | 455 } |
466 | 456 |
467 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth
and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN
ode, bool allowVisitedStyle) | 457 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth
and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN
ode, bool allowVisitedStyle) |
468 { | 458 { |
469 CSSValueList* list = CSSValueList::createSlashSeparated(); | 459 CSSValueList* list = CSSValueList::createSlashSeparated(); |
470 for (size_t i = 0; i < shorthand.length(); ++i) { | 460 for (size_t i = 0; i < shorthand.length(); ++i) { |
471 const CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.prop
erties()[i], style, layoutObject, styledNode, allowVisitedStyle); | 461 const CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.prop
erties()[i], style, layoutObject, styledNode, allowVisitedStyle); |
472 ASSERT(value); | 462 ASSERT(value); |
(...skipping 1412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1885 } | 1875 } |
1886 case CSSPropertyDirection: | 1876 case CSSPropertyDirection: |
1887 return CSSPrimitiveValue::create(style.direction()); | 1877 return CSSPrimitiveValue::create(style.direction()); |
1888 case CSSPropertyDisplay: | 1878 case CSSPropertyDisplay: |
1889 return CSSPrimitiveValue::create(style.display()); | 1879 return CSSPrimitiveValue::create(style.display()); |
1890 case CSSPropertyEmptyCells: | 1880 case CSSPropertyEmptyCells: |
1891 return CSSPrimitiveValue::create(style.emptyCells()); | 1881 return CSSPrimitiveValue::create(style.emptyCells()); |
1892 case CSSPropertyAlignContent: | 1882 case CSSPropertyAlignContent: |
1893 return valueForContentPositionAndDistributionWithOverflowAlignment(style
.alignContent()); | 1883 return valueForContentPositionAndDistributionWithOverflowAlignment(style
.alignContent()); |
1894 case CSSPropertyAlignItems: | 1884 case CSSPropertyAlignItems: |
1895 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac
yPosition); | 1885 return valueForItemPositionWithOverflowAlignment(style.alignItems()); |
1896 case CSSPropertyAlignSelf: { | 1886 case CSSPropertyAlignSelf: |
1897 ItemPosition position = style.alignSelfPosition(); | 1887 return valueForItemPositionWithOverflowAlignment(style.alignSelf()); |
1898 if (position == ItemPositionAuto) { | |
1899 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par
entComputedStyle) | |
1900 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled
Node->parentNode()->ensureComputedStyle() : nullptr; | |
1901 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl
e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle))
: ItemPositionStart; | |
1902 } | |
1903 return valueForItemPositionWithOverflowAlignment(position, style.alignSe
lfOverflowAlignment(), NonLegacyPosition); | |
1904 } | |
1905 case CSSPropertyFlex: | 1888 case CSSPropertyFlex: |
1906 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); | 1889 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); |
1907 case CSSPropertyFlexBasis: | 1890 case CSSPropertyFlexBasis: |
1908 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); | 1891 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); |
1909 case CSSPropertyFlexDirection: | 1892 case CSSPropertyFlexDirection: |
1910 return CSSPrimitiveValue::create(style.flexDirection()); | 1893 return CSSPrimitiveValue::create(style.flexDirection()); |
1911 case CSSPropertyFlexFlow: | 1894 case CSSPropertyFlexFlow: |
1912 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); | 1895 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); |
1913 case CSSPropertyFlexGrow: | 1896 case CSSPropertyFlexGrow: |
1914 return CSSPrimitiveValue::create(style.flexGrow(), CSSPrimitiveValue::Un
itType::Number); | 1897 return CSSPrimitiveValue::create(style.flexGrow(), CSSPrimitiveValue::Un
itType::Number); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2049 return CSSStringValue::create(style.hyphenationString()); | 2032 return CSSStringValue::create(style.hyphenationString()); |
2050 case CSSPropertyImageRendering: | 2033 case CSSPropertyImageRendering: |
2051 return CSSPrimitiveValue::create(style.imageRendering()); | 2034 return CSSPrimitiveValue::create(style.imageRendering()); |
2052 case CSSPropertyImageOrientation: | 2035 case CSSPropertyImageOrientation: |
2053 if (style.respectImageOrientation() == RespectImageOrientation) | 2036 if (style.respectImageOrientation() == RespectImageOrientation) |
2054 return CSSPrimitiveValue::createIdentifier(CSSValueFromImage); | 2037 return CSSPrimitiveValue::createIdentifier(CSSValueFromImage); |
2055 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Degrees
); | 2038 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Degrees
); |
2056 case CSSPropertyIsolation: | 2039 case CSSPropertyIsolation: |
2057 return CSSPrimitiveValue::create(style.isolation()); | 2040 return CSSPrimitiveValue::create(style.isolation()); |
2058 case CSSPropertyJustifyItems: | 2041 case CSSPropertyJustifyItems: |
2059 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl
e.justifyItemsPositionType()); | 2042 return valueForItemPositionWithOverflowAlignment(style.justifyItems()); |
2060 case CSSPropertyJustifySelf: { | 2043 case CSSPropertyJustifySelf: |
2061 Node* parent = styledNode->parentNode(); | 2044 return valueForItemPositionWithOverflowAlignment(style.justifySelf()); |
2062 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st
yle.justifySelfOverflowAlignment(), NonLegacyPosition); | |
2063 } | |
2064 case CSSPropertyLeft: | 2045 case CSSPropertyLeft: |
2065 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); | 2046 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); |
2066 case CSSPropertyLetterSpacing: | 2047 case CSSPropertyLetterSpacing: |
2067 if (!style.letterSpacing()) | 2048 if (!style.letterSpacing()) |
2068 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); | 2049 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
2069 return zoomAdjustedPixelValue(style.letterSpacing(), style); | 2050 return zoomAdjustedPixelValue(style.letterSpacing(), style); |
2070 case CSSPropertyWebkitLineClamp: | 2051 case CSSPropertyWebkitLineClamp: |
2071 if (style.lineClamp().isNone()) | 2052 if (style.lineClamp().isNone()) |
2072 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 2053 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
2073 return CSSPrimitiveValue::create(style.lineClamp().value(), style.lineCl
amp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVal
ue::UnitType::Number); | 2054 return CSSPrimitiveValue::create(style.lineClamp().value(), style.lineCl
amp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVal
ue::UnitType::Number); |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3021 case CSSPropertyAll: | 3002 case CSSPropertyAll: |
3022 return nullptr; | 3003 return nullptr; |
3023 default: | 3004 default: |
3024 break; | 3005 break; |
3025 } | 3006 } |
3026 ASSERT_NOT_REACHED(); | 3007 ASSERT_NOT_REACHED(); |
3027 return nullptr; | 3008 return nullptr; |
3028 } | 3009 } |
3029 | 3010 |
3030 } // namespace blink | 3011 } // namespace blink |
OLD | NEW |