Commit 52544b2c authored by timloh@chromium.org's avatar timloh@chromium.org

Slightly simplify building FillLayer objects

Review URL: https://codereview.chromium.org/405093002

git-svn-id: svn://svn.chromium.org/blink/trunk@178546 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent ea0502db
......@@ -400,11 +400,8 @@ static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt
FillLayer* prevChild = 0;
const FillLayer* currParent = &state.parentStyle()->{{layer_type|lower}}Layers();
while (currParent && currParent->is{{fill_type}}Set()) {
if (!currChild) {
/* Need to make a new layer.*/
currChild = new FillLayer({{fill_layer_type}});
prevChild->setNext(currChild);
}
if (!currChild)
currChild = prevChild->ensureNext();
currChild->set{{fill_type}}(currParent->{{fill_type|lower_first}}());
prevChild = currChild;
currChild = prevChild->next();
......@@ -426,11 +423,8 @@ static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt
/* Walk each value and put it into a layer, creating new layers as needed. */
CSSValueList* valueList = toCSSValueList(value);
for (unsigned int i = 0; i < valueList->length(); i++) {
if (!currChild) {
/* Need to make a new layer to hold this value */
currChild = new FillLayer({{fill_layer_type}});
prevChild->setNext(currChild);
}
if (!currChild)
currChild = prevChild->ensureNext();
state.styleMap().{{map_fill}}({{property_id}}, currChild, valueList->item(i));
prevChild = currChild;
currChild = currChild->next();
......
......@@ -151,26 +151,8 @@ void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleR
FillLayer* fillLayer = &fillLayers;
FillLayer* prev = 0;
for (size_t i = 0; i < values.size(); ++i) {
if (!fillLayer) {
switch (property) {
case CSSPropertyBackgroundImage:
case CSSPropertyBackgroundPositionX:
case CSSPropertyBackgroundPositionY:
case CSSPropertyBackgroundSize:
case CSSPropertyWebkitBackgroundSize:
fillLayer = new FillLayer(BackgroundFillLayer);
break;
case CSSPropertyWebkitMaskImage:
case CSSPropertyWebkitMaskPositionX:
case CSSPropertyWebkitMaskPositionY:
case CSSPropertyWebkitMaskSize:
fillLayer = new FillLayer(MaskFillLayer);
break;
default:
ASSERT_NOT_REACHED();
}
prev->setNext(fillLayer);
}
if (!fillLayer)
fillLayer = prev->ensureNext();
const AnimatableValue* layerValue = values[i].get();
switch (property) {
case CSSPropertyBackgroundImage:
......
......@@ -84,6 +84,12 @@ public:
const FillLayer* next() const { return m_next; }
FillLayer* next() { return m_next; }
FillLayer* ensureNext()
{
if (!m_next)
m_next = new FillLayer(type());
return m_next;
}
bool isImageSet() const { return m_imageSet; }
bool isXPositionSet() const { return m_xPosSet; }
......@@ -139,8 +145,6 @@ public:
void clearSize() { m_sizeType = SizeNone; }
void clearMaskSourceType() { m_maskSourceTypeSet = false; }
void setNext(FillLayer* n) { if (m_next != n) { delete m_next; m_next = n; } }
FillLayer& operator=(const FillLayer& o);
FillLayer(const FillLayer& o);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment