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 ...@@ -400,11 +400,8 @@ static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt
FillLayer* prevChild = 0; FillLayer* prevChild = 0;
const FillLayer* currParent = &state.parentStyle()->{{layer_type|lower}}Layers(); const FillLayer* currParent = &state.parentStyle()->{{layer_type|lower}}Layers();
while (currParent && currParent->is{{fill_type}}Set()) { while (currParent && currParent->is{{fill_type}}Set()) {
if (!currChild) { if (!currChild)
/* Need to make a new layer.*/ currChild = prevChild->ensureNext();
currChild = new FillLayer({{fill_layer_type}});
prevChild->setNext(currChild);
}
currChild->set{{fill_type}}(currParent->{{fill_type|lower_first}}()); currChild->set{{fill_type}}(currParent->{{fill_type|lower_first}}());
prevChild = currChild; prevChild = currChild;
currChild = prevChild->next(); currChild = prevChild->next();
...@@ -426,11 +423,8 @@ static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt ...@@ -426,11 +423,8 @@ static bool lengthTypeAndValueMatch(const BorderImageLengthBox& borderImageLengt
/* Walk each value and put it into a layer, creating new layers as needed. */ /* Walk each value and put it into a layer, creating new layers as needed. */
CSSValueList* valueList = toCSSValueList(value); CSSValueList* valueList = toCSSValueList(value);
for (unsigned int i = 0; i < valueList->length(); i++) { for (unsigned int i = 0; i < valueList->length(); i++) {
if (!currChild) { if (!currChild)
/* Need to make a new layer to hold this value */ currChild = prevChild->ensureNext();
currChild = new FillLayer({{fill_layer_type}});
prevChild->setNext(currChild);
}
state.styleMap().{{map_fill}}({{property_id}}, currChild, valueList->item(i)); state.styleMap().{{map_fill}}({{property_id}}, currChild, valueList->item(i));
prevChild = currChild; prevChild = currChild;
currChild = currChild->next(); currChild = currChild->next();
......
...@@ -151,26 +151,8 @@ void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleR ...@@ -151,26 +151,8 @@ void setOnFillLayers(FillLayer& fillLayers, const AnimatableValue* value, StyleR
FillLayer* fillLayer = &fillLayers; FillLayer* fillLayer = &fillLayers;
FillLayer* prev = 0; FillLayer* prev = 0;
for (size_t i = 0; i < values.size(); ++i) { for (size_t i = 0; i < values.size(); ++i) {
if (!fillLayer) { if (!fillLayer)
switch (property) { fillLayer = prev->ensureNext();
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);
}
const AnimatableValue* layerValue = values[i].get(); const AnimatableValue* layerValue = values[i].get();
switch (property) { switch (property) {
case CSSPropertyBackgroundImage: case CSSPropertyBackgroundImage:
......
...@@ -84,6 +84,12 @@ public: ...@@ -84,6 +84,12 @@ public:
const FillLayer* next() const { return m_next; } const FillLayer* next() const { return m_next; }
FillLayer* next() { 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 isImageSet() const { return m_imageSet; }
bool isXPositionSet() const { return m_xPosSet; } bool isXPositionSet() const { return m_xPosSet; }
...@@ -139,8 +145,6 @@ public: ...@@ -139,8 +145,6 @@ public:
void clearSize() { m_sizeType = SizeNone; } void clearSize() { m_sizeType = SizeNone; }
void clearMaskSourceType() { m_maskSourceTypeSet = false; } 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& operator=(const FillLayer& o);
FillLayer(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