Index: Source/platform/graphics/paint/DisplayItemList.cpp |
diff --git a/Source/platform/graphics/paint/DisplayItemList.cpp b/Source/platform/graphics/paint/DisplayItemList.cpp |
index ee2725863ab42b67128bbadcfde853b2c301746d..d3df77d2371c2f87b1b7cdcd581fdf1cecd82d9c 100644 |
--- a/Source/platform/graphics/paint/DisplayItemList.cpp |
+++ b/Source/platform/graphics/paint/DisplayItemList.cpp |
@@ -32,52 +32,43 @@ const DisplayItems& DisplayItemList::displayItems() const |
return m_currentDisplayItems; |
} |
-void DisplayItemList::add(WTF::PassOwnPtr<DisplayItem> displayItem) |
+void DisplayItemList::processNewItem(DisplayItem& addedDisplayItem) |
{ |
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); |
ASSERT(!m_constructionDisabled); |
- ASSERT(!skippingCache() || !displayItem->isCached()); |
+ ASSERT(!skippingCache() || !addedDisplayItem.isCached()); |
- if (displayItem->isEnd()) { |
- ASSERT(!m_newDisplayItems.isEmpty()); |
- if (m_newDisplayItems.last().isBegin() && !m_newDisplayItems.last().drawsContent()) { |
- ASSERT(displayItem->isEndAndPairedWith(m_newDisplayItems.last().type())); |
- // Remove the beginning display item of this empty pair. |
- m_newDisplayItems.removeLast(); |
+ if (addedDisplayItem.isEnd()) { |
+ ASSERT(m_newDisplayItems.size() >= 2); |
+ DisplayItems::ItemHandle previousDisplayItem = m_newDisplayItems[m_newDisplayItems.size() - 2]; |
+ if (previousDisplayItem.isBegin() && !previousDisplayItem.drawsContent()) { |
#if ENABLE(ASSERT) |
- // Also remove the index pointing to the removed display item. |
- DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient.find(displayItem->client()); |
+ ASSERT(addedDisplayItem.isEndAndPairedWith(previousDisplayItem.type())); |
+ // Remove the index pointing to the begin display item. |
+ DisplayItemIndicesByClientMap::iterator it = m_newDisplayItemIndicesByClient.find(previousDisplayItem.client()); |
if (it != m_newDisplayItemIndicesByClient.end()) { |
Vector<size_t>& indices = it->value; |
- if (!indices.isEmpty() && indices.last() == m_newDisplayItems.size()) |
+ if (!indices.isEmpty() && indices.last() == m_newDisplayItems.size() - 1) |
indices.removeLast(); |
} |
#endif |
+ // Remove the no-op pair. |
+ m_newDisplayItems.removeLast(); |
+ m_newDisplayItems.removeLast(); |
return; |
} |
} |
if (!m_scopeStack.isEmpty()) |
- displayItem->setScope(m_scopeStack.last().id, m_scopeStack.last().client); |
+ addedDisplayItem.setScope(m_scopeStack.last().id, m_scopeStack.last().client); |
#if ENABLE(ASSERT) |
- size_t index = findMatchingItemFromIndex(displayItem->id(), displayItem->type(), m_newDisplayItemIndicesByClient, m_newDisplayItems); |
- if (index != kNotFound) { |
-#ifndef NDEBUG |
- showDebugData(); |
- WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=%d)\n", |
- displayItem->asDebugString().utf8().data(), m_newDisplayItems[index].asDebugString().utf8().data(), static_cast<int>(index)); |
+ addItemToIndex(addedDisplayItem.client(), addedDisplayItem.type(), m_newDisplayItems.size() - 1, m_newDisplayItemIndicesByClient); |
#endif |
- ASSERT_NOT_REACHED(); |
Xianzhu
2015/06/19 16:19:11
Is the above code moved elsewhere or removed?
|
- } |
- addItemToIndex(displayItem->client(), displayItem->type(), m_newDisplayItems.size(), m_newDisplayItemIndicesByClient); |
-#endif // ENABLE(ASSERT) |
- ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the flag. |
+ ASSERT(!addedDisplayItem.skippedCache()); // Only DisplayItemList can set the flag. |
if (skippingCache()) |
- displayItem->setSkippedCache(); |
- |
- m_newDisplayItems.append(displayItem); |
+ addedDisplayItem.setSkippedCache(); |
} |
void DisplayItemList::beginScope(DisplayItemClient client) |