Changeset 201498 in webkit for trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
- Timestamp:
- May 30, 2016, 1:14:31 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r201290 r201498 2276 2276 } 2277 2277 2278 static ItemPosition resolveContainerAlignmentAuto(ItemPosition position, RenderObject* element) 2279 { 2280 if (position != ItemPositionAuto || !element) 2281 return position; 2282 2283 return element->style().isDisplayFlexibleOrGridBox() ? ItemPositionStretch : ItemPositionStart; 2284 } 2285 2286 static ItemPosition resolveSelfAlignmentAuto(ItemPosition position, OverflowAlignment& overflow, RenderObject* element) 2287 { 2288 if (position != ItemPositionAuto || !element || element->isOutOfFlowPositioned()) 2289 return position; 2290 2291 RenderBlock* parent = element->containingBlock(); 2292 if (!parent) 2293 return ItemPositionStart; 2294 2295 overflow = parent->style().alignItemsOverflowAlignment(); 2296 return resolveContainerAlignmentAuto(parent->style().alignItemsPosition(), parent); 2278 static StyleSelfAlignmentData resolveLegacyJustifyItems(const StyleSelfAlignmentData& data) 2279 { 2280 if (data.positionType() == LegacyPosition) 2281 return { data.position(), OverflowAlignmentDefault }; 2282 return data; 2283 } 2284 2285 static StyleSelfAlignmentData resolveJustifyItemsAuto(const StyleSelfAlignmentData& data, Node* parent) 2286 { 2287 if (data.position() != ItemPositionAuto) 2288 return data; 2289 2290 // If the inherited value of justify-items includes the 'legacy' keyword, 'auto' computes to the inherited value. 2291 const auto& inheritedValue = (!parent || !parent->computedStyle()) ? RenderStyle::initialDefaultAlignment() : parent->computedStyle()->justifyItems(); 2292 if (inheritedValue.positionType() == LegacyPosition) 2293 return inheritedValue; 2294 if (inheritedValue.position() == ItemPositionAuto) 2295 return resolveJustifyItemsAuto(inheritedValue, parent->parentNode()); 2296 return { ItemPositionNormal, OverflowAlignmentDefault }; 2297 } 2298 2299 static StyleSelfAlignmentData resolveJustifySelfAuto(const StyleSelfAlignmentData& data, Node* parent) 2300 { 2301 if (data.position() != ItemPositionAuto) 2302 return data; 2303 2304 // The 'auto' keyword computes to the computed value of justify-items on the parent or 'normal' if the box has no parent. 2305 if (!parent || !parent->computedStyle()) 2306 return { ItemPositionNormal, OverflowAlignmentDefault }; 2307 return resolveLegacyJustifyItems(resolveJustifyItemsAuto(parent->computedStyle()->justifyItems(), parent->parentNode())); 2308 } 2309 2310 static StyleSelfAlignmentData resolveAlignSelfAuto(const StyleSelfAlignmentData& data, Node* parent) 2311 { 2312 if (data.position() != ItemPositionAuto) 2313 return data; 2314 2315 // The 'auto' keyword computes to the computed value of align-items on the parent or 'normal' if the box has no parent. 2316 if (!parent || !parent->computedStyle()) 2317 return { ItemPositionNormal, OverflowAlignmentDefault }; 2318 return parent->computedStyle()->alignItems(); 2297 2319 } 2298 2320 … … 2377 2399 #endif 2378 2400 2379 static Ref Ptr<CSSValueList> valueForItemPositionWithOverflowAlignment(ItemPosition itemPosition, OverflowAlignment overflowAlignment, ItemPositionType positionType)2401 static Ref<CSSValueList> valueForItemPositionWithOverflowAlignment(const StyleSelfAlignmentData& data) 2380 2402 { 2381 2403 auto& cssValuePool = CSSValuePool::singleton(); 2382 RefPtr<CSSValueList>result = CSSValueList::createSpaceSeparated();2383 if ( positionType== LegacyPosition)2384 result ->append(CSSPrimitiveValue::createIdentifier(CSSValueLegacy));2385 result ->append(cssValuePool.createValue(itemPosition));2386 if ( overflowAlignment!= OverflowAlignmentDefault)2387 result ->append(cssValuePool.createValue(overflowAlignment));2388 ASSERT(result ->length() <= 2);2404 auto result = CSSValueList::createSpaceSeparated(); 2405 if (data.positionType() == LegacyPosition) 2406 result.get().append(cssValuePool.createIdentifierValue(CSSValueLegacy)); 2407 result.get().append(cssValuePool.createValue(data.position())); 2408 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlignmentDefault) 2409 result.get().append(cssValuePool.createValue(data.overflow())); 2410 ASSERT(result.get().length() <= 2); 2389 2411 return result; 2390 2412 } 2391 2413 2392 static RefPtr<CSSValueList> valueForContentPositionAndDistributionWithOverflowAlignment(const StyleContentAlignmentData& data) 2393 { 2394 RefPtr<CSSValueList> result = CSSValueList::createSpaceSeparated(); 2414 static Ref<CSSValueList> valueForContentPositionAndDistributionWithOverflowAlignment(const StyleContentAlignmentData& data) 2415 { 2416 auto& cssValuePool = CSSValuePool::singleton(); 2417 auto result = CSSValueList::createSpaceSeparated(); 2395 2418 if (data.distribution() != ContentDistributionDefault) 2396 result ->append(CSSPrimitiveValue::create(data.distribution()));2419 result.get().append(cssValuePool.createValue(data.distribution())); 2397 2420 if (data.distribution() == ContentDistributionDefault || data.position() != ContentPositionNormal) 2398 result ->append(CSSPrimitiveValue::create(data.position()));2421 result.get().append(cssValuePool.createValue(data.position())); 2399 2422 if ((data.position() >= ContentPositionCenter || data.distribution() != ContentDistributionDefault) && data.overflow() != OverflowAlignmentDefault) 2400 result ->append(CSSPrimitiveValue::create(data.overflow()));2401 ASSERT(result ->length() > 0);2402 ASSERT(result ->length() <= 3);2423 result.get().append(cssValuePool.createValue(data.overflow())); 2424 ASSERT(result.get().length() > 0); 2425 ASSERT(result.get().length() <= 3); 2403 2426 return result; 2404 2427 } … … 2780 2803 return valueForContentPositionAndDistributionWithOverflowAlignment(style->alignContent()); 2781 2804 case CSSPropertyAlignItems: 2782 return valueForItemPositionWithOverflowAlignment(resolveContainerAlignmentAuto(style->alignItemsPosition(), renderer), style->alignItemsOverflowAlignment(), NonLegacyPosition); 2783 case CSSPropertyAlignSelf: { 2784 OverflowAlignment overflow = style->alignSelfOverflowAlignment(); 2785 ItemPosition alignSelf = resolveSelfAlignmentAuto(style->alignSelfPosition(), overflow, renderer); 2786 return valueForItemPositionWithOverflowAlignment(alignSelf, overflow, NonLegacyPosition); 2787 } 2805 return valueForItemPositionWithOverflowAlignment(style->alignItems()); 2806 case CSSPropertyAlignSelf: 2807 return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(style->alignSelf(), styledNode->parentNode())); 2788 2808 case CSSPropertyFlex: 2789 2809 return getCSSPropertyValuesForShorthandProperties(flexShorthand()); … … 2803 2823 return valueForContentPositionAndDistributionWithOverflowAlignment(style->justifyContent()); 2804 2824 case CSSPropertyJustifyItems: 2805 return valueForItemPositionWithOverflowAlignment(resolveContainerAlignmentAuto(style->justifyItemsPosition(), renderer), style->justifyItemsOverflowAlignment(), style->justifyItemsPositionType()); 2806 case CSSPropertyJustifySelf: { 2807 OverflowAlignment overflow = style->justifySelfOverflowAlignment(); 2808 ItemPosition justifySelf = resolveSelfAlignmentAuto(style->justifySelfPosition(), overflow, renderer); 2809 return valueForItemPositionWithOverflowAlignment(justifySelf, overflow, NonLegacyPosition); 2810 } 2825 return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto(style->justifyItems(), styledNode->parentNode())); 2826 case CSSPropertyJustifySelf: 2827 return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style->justifySelf(), styledNode->parentNode())); 2811 2828 case CSSPropertyOrder: 2812 2829 return cssValuePool.createValue(style->order(), CSSPrimitiveValue::CSS_NUMBER);
Note:
See TracChangeset
for help on using the changeset viewer.