Commit 6472f37a authored by pdr@chromium.org's avatar pdr@chromium.org

Cleanup DisplayItemList::processNewItem to take a reference

This patch fixes an old TODO where processNewItem took a pointer
to make the initial review easier. The pointer indirection is not
necessary and has been switched to a reference.

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

git-svn-id: svn://svn.chromium.org/blink/trunk@201657 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 04e1cb25
...@@ -59,43 +59,43 @@ void DisplayItemList::removeLastDisplayItem() ...@@ -59,43 +59,43 @@ void DisplayItemList::removeLastDisplayItem()
m_newDisplayItems.removeLast(); m_newDisplayItems.removeLast();
} }
void DisplayItemList::processNewItem(DisplayItem* displayItem) void DisplayItemList::processNewItem(DisplayItem& displayItem)
{ {
ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled()); ASSERT(RuntimeEnabledFeatures::slimmingPaintEnabled());
ASSERT(!m_constructionDisabled); ASSERT(!m_constructionDisabled);
ASSERT(!skippingCache() || !displayItem->isCached()); ASSERT(!skippingCache() || !displayItem.isCached());
if (displayItem->isCached()) if (displayItem.isCached())
++m_numCachedItems; ++m_numCachedItems;
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
// Verify noop begin/end pairs have been removed. // Verify noop begin/end pairs have been removed.
if (m_newDisplayItems.size() >= 2 && displayItem->isEnd()) { if (m_newDisplayItems.size() >= 2 && displayItem.isEnd()) {
const auto& beginDisplayItem = m_newDisplayItems[m_newDisplayItems.size() - 2]; const auto& beginDisplayItem = m_newDisplayItems[m_newDisplayItems.size() - 2];
if (beginDisplayItem.isBegin() && beginDisplayItem.type() != DisplayItem::BeginSubsequence && !beginDisplayItem.drawsContent()) if (beginDisplayItem.isBegin() && beginDisplayItem.type() != DisplayItem::BeginSubsequence && !beginDisplayItem.drawsContent())
ASSERT(!displayItem->isEndAndPairedWith(beginDisplayItem.type())); ASSERT(!displayItem.isEndAndPairedWith(beginDisplayItem.type()));
} }
#endif #endif
if (!m_scopeStack.isEmpty()) if (!m_scopeStack.isEmpty())
displayItem->setScope(m_scopeStack.last()); displayItem.setScope(m_scopeStack.last());
#if ENABLE(ASSERT) #if ENABLE(ASSERT)
size_t index = findMatchingItemFromIndex(displayItem->nonCachedId(), m_newDisplayItemIndicesByClient, m_newDisplayItems); size_t index = findMatchingItemFromIndex(displayItem.nonCachedId(), m_newDisplayItemIndicesByClient, m_newDisplayItems);
if (index != kNotFound) { if (index != kNotFound) {
#ifndef NDEBUG #ifndef NDEBUG
showDebugData(); showDebugData();
WTFLogAlways("DisplayItem %s has duplicated id with previous %s (index=%d)\n", 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)); displayItem.asDebugString().utf8().data(), m_newDisplayItems[index].asDebugString().utf8().data(), static_cast<int>(index));
#endif #endif
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
addItemToIndexIfNeeded(*displayItem, m_newDisplayItems.size() - 1, m_newDisplayItemIndicesByClient); addItemToIndexIfNeeded(displayItem, m_newDisplayItems.size() - 1, m_newDisplayItemIndicesByClient);
#endif // ENABLE(ASSERT) #endif // ENABLE(ASSERT)
ASSERT(!displayItem->skippedCache()); // Only DisplayItemList can set the flag. ASSERT(!displayItem.skippedCache()); // Only DisplayItemList can set the flag.
if (skippingCache()) if (skippingCache())
displayItem->setSkippedCache(); displayItem.setSkippedCache();
} }
void DisplayItemList::beginScope() void DisplayItemList::beginScope()
......
...@@ -70,7 +70,7 @@ public: ...@@ -70,7 +70,7 @@ public:
"DisplayItem subclass is larger than kMaximumDisplayItemSize."); "DisplayItem subclass is larger than kMaximumDisplayItemSize.");
DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<DisplayItemClass>(WTF::forward<Args>(args)...); DisplayItemClass& displayItem = m_newDisplayItems.allocateAndConstruct<DisplayItemClass>(WTF::forward<Args>(args)...);
processNewItem(&displayItem); processNewItem(displayItem);
return displayItem; return displayItem;
} }
...@@ -157,8 +157,7 @@ private: ...@@ -157,8 +157,7 @@ private:
friend class LayoutObjectDrawingRecorderTestForSlimmingPaintV2; friend class LayoutObjectDrawingRecorderTestForSlimmingPaintV2;
// Set new item state (scopes, cache skipping, etc) for a new item. // Set new item state (scopes, cache skipping, etc) for a new item.
// TODO(pdr): This only passes a pointer to make the patch easier to review. Change to a reference. void processNewItem(DisplayItem&);
void processNewItem(DisplayItem*);
void updateValidlyCachedClientsIfNeeded() const; void updateValidlyCachedClientsIfNeeded() const;
......
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