Changeset 286200 in webkit for trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
- Timestamp:
- Nov 28, 2021, 2:24:05 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r286086 r286200 4448 4448 } 4449 4449 4450 size_t ComputedStyleExtractor::getLayerCount(CSSPropertyID property) 4451 { 4452 ASSERT(property == CSSPropertyBackground || property == CSSPropertyMask); 4453 if (!styledElement()) 4454 return 0; 4455 4456 std::unique_ptr<RenderStyle> ownedStyle; 4457 const RenderStyle* style = computeRenderStyleForProperty(*styledElement(), m_pseudoElementSpecifier, property, ownedStyle); 4458 if (!style) 4459 return 0; 4460 4461 auto& layers = property == CSSPropertyMask ? style->maskLayers() : style->backgroundLayers(); 4462 4463 size_t layerCount = 0; 4464 for (auto* currLayer = &layers; currLayer; currLayer = currLayer->next()) 4465 layerCount++; 4466 return layerCount; 4467 } 4468 4469 Ref<CSSValueList> ComputedStyleExtractor::getFillLayerPropertyShorthandValue(CSSPropertyID property, const StylePropertyShorthand& propertiesBeforeSlashSeparator, const StylePropertyShorthand& propertiesAfterSlashSeparator, CSSPropertyID lastLayerProperty) 4470 { 4471 ASSERT(property == CSSPropertyBackground || property == CSSPropertyMask); 4472 size_t layerCount = getLayerCount(property); 4473 ASSERT(layerCount); 4474 4475 auto lastValue = lastLayerProperty != CSSPropertyInvalid ? propertyValue(lastLayerProperty, DoNotUpdateLayout) : nullptr; 4476 auto before = getCSSPropertyValuesForShorthandProperties(propertiesBeforeSlashSeparator); 4477 auto after = getCSSPropertyValuesForShorthandProperties(propertiesAfterSlashSeparator); 4478 4479 // The computed properties are returned as lists of properties, with a list of layers in each. 4480 // We want to swap that around to have a list of layers, with a list of properties in each. 4481 4482 auto layers = CSSValueList::createCommaSeparated(); 4483 4484 for (size_t i = 0; i < layerCount; i++) { 4485 auto list = CSSValueList::createSlashSeparated(); 4486 auto beforeList = CSSValueList::createSpaceSeparated(); 4487 4488 if (i == layerCount - 1 && lastValue) 4489 beforeList->append(*lastValue); 4490 4491 for (size_t j = 0; j < propertiesBeforeSlashSeparator.length(); j++) { 4492 auto& value = *before->item(j); 4493 beforeList->append(layerCount == 1 ? value : *downcast<CSSValueList>(value).item(i)); 4494 } 4495 list->append(beforeList); 4496 4497 auto afterList = CSSValueList::createSpaceSeparated(); 4498 for (size_t j = 0; j < propertiesAfterSlashSeparator.length(); j++) { 4499 auto& value = *after->item(j); 4500 afterList->append(layerCount == 1 ? value : *downcast<CSSValueList>(value).item(i)); 4501 } 4502 list->append(afterList); 4503 4504 if (layerCount == 1) 4505 return list; 4506 4507 layers->append(list); 4508 } 4509 4510 return layers; 4511 } 4512 4513 4450 4514 Ref<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() 4451 4515 { 4452 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition }; 4453 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, CSSPropertyBackgroundClip }; 4454 4455 auto list = CSSValueList::createSlashSeparated(); 4456 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator))); 4457 list->append(getCSSPropertyValuesForShorthandProperties(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator))); 4458 return list; 4516 static const CSSPropertyID propertiesBeforeSlashSeparator[] = { CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition }; 4517 static const CSSPropertyID propertiesAfterSlashSeparator[] = { CSSPropertyBackgroundSize, CSSPropertyBackgroundOrigin, CSSPropertyBackgroundClip }; 4518 4519 return getFillLayerPropertyShorthandValue(CSSPropertyBackground, StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeparator), StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeparator), CSSPropertyBackgroundColor); 4459 4520 } 4460 4521
Note:
See TracChangeset
for help on using the changeset viewer.