Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(527)

Unified Diff: Source/core/css/RenderStyleCSSValueMapping.cpp

Issue 879993003: Fix serialization of background property with multiple layers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add test Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/fast/backgrounds/background-shorthand-multiple-layers-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RenderStyleCSSValueMapping.cpp
diff --git a/Source/core/css/RenderStyleCSSValueMapping.cpp b/Source/core/css/RenderStyleCSSValueMapping.cpp
index cb0f8fe595b9a05ab78be4536b4eed9464a94ba3..8d89aa9dc131873d17ccd32d4800969d3751b9cc 100644
--- a/Source/core/css/RenderStyleCSSValueMapping.cpp
+++ b/Source/core/css/RenderStyleCSSValueMapping.cpp
@@ -414,23 +414,29 @@ static PassRefPtrWillBeRawPtr<CSSValueList> valuesForShorthandProperty(const Sty
static PassRefPtrWillBeRawPtr<CSSValueList> valuesForBackgroundShorthand(const RenderStyle& style, const RenderObject* renderer, Node* styledNode, bool allowVisitedStyle)
{
- static const CSSPropertyID propertiesBeforeSlashSeperator[] = {
- CSSPropertyBackgroundColor,
- CSSPropertyBackgroundImage,
- CSSPropertyBackgroundRepeat,
- CSSPropertyBackgroundAttachment,
- CSSPropertyBackgroundPosition
- };
- static const CSSPropertyID propertiesAfterSlashSeperator[] = {
- CSSPropertyBackgroundSize,
- CSSPropertyBackgroundOrigin,
- CSSPropertyBackgroundClip
- };
-
- RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
- list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBackground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlashSeperator)), style, renderer, styledNode, allowVisitedStyle));
- list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBackground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSeperator)), style, renderer, styledNode, allowVisitedStyle));
- return list.release();
+ RefPtrWillBeRawPtr<CSSValueList> ret = CSSValueList::createCommaSeparated();
+ const FillLayer* currLayer = &style.backgroundLayers();
+ for (; currLayer; currLayer = currLayer->next()) {
+ RefPtrWillBeRawPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
+ RefPtrWillBeRawPtr<CSSValueList> beforeSlash = CSSValueList::createSpaceSeparated();
+ if (!currLayer->next()) { // color only for final layer
+ RefPtrWillBeRawPtr<CSSValue> value = RenderStyleCSSValueMapping::get(CSSPropertyBackgroundColor, style, renderer, styledNode, allowVisitedStyle);
+ ASSERT(value);
+ beforeSlash->append(value);
+ }
+ beforeSlash->append(currLayer->image() ? currLayer->image()->cssValue() : cssValuePool().createIdentifierValue(CSSValueNone));
+ beforeSlash->append(valueForFillRepeat(currLayer->repeatX(), currLayer->repeatY()));
+ beforeSlash->append(cssValuePool().createValue(currLayer->attachment()));
+ beforeSlash->append(createPositionListForLayer(CSSPropertyBackgroundPosition, *currLayer, style));
+ list->append(beforeSlash);
+ RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceSeparated();
+ afterSlash->append(valueForFillSize(currLayer->size(), style));
+ afterSlash->append(cssValuePool().createValue(currLayer->origin()));
+ afterSlash->append(cssValuePool().createValue(currLayer->clip()));
+ list->append(afterSlash);
+ ret->append(list);
+ }
+ return ret.release();
}
static ContentPosition resolveContentAlignmentAuto(ContentPosition position, ContentDistributionType distribution, Node* element)
« no previous file with comments | « LayoutTests/fast/backgrounds/background-shorthand-multiple-layers-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698