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

Unified Diff: Source/core/rendering/FastTextAutosizer.cpp

Issue 186453002: [FastTextAutosizer] Keep m_blocksForFingerprint and m_fingerprints in sync (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address reviewer comments Created 6 years, 10 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 | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/FastTextAutosizer.cpp
diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp
index bd0810acda0e91a23b4cad15404c8a0c8b1f1cbf..4344046b8a8ae9f31010c1d7e4dae442607006aa 100644
--- a/Source/core/rendering/FastTextAutosizer.cpp
+++ b/Source/core/rendering/FastTextAutosizer.cpp
@@ -659,9 +659,31 @@ FastTextAutosizer::Cluster* FastTextAutosizer::currentCluster() const
return m_clusterStack.last().get();
}
+#ifndef NDEBUG
+void FastTextAutosizer::FingerprintMapper::assertMapsAreConsistent()
+{
+ // For each fingerprint -> block mapping in m_blocksForFingerprint we should have an associated
+ // map from block -> fingerprint in m_fingerprints.
+ ReverseFingerprintMap::iterator end = m_blocksForFingerprint.end();
+ for (ReverseFingerprintMap::iterator fingerprintIt = m_blocksForFingerprint.begin(); fingerprintIt != end; ++fingerprintIt) {
+ Fingerprint fingerprint = fingerprintIt->key;
+ BlockSet* blocks = fingerprintIt->value.get();
+ for (BlockSet::iterator blockIt = blocks->begin(); blockIt != blocks->end(); ++blockIt) {
+ const RenderBlock* block = (*blockIt);
+ ASSERT(m_fingerprints.get(block) == fingerprint);
+ }
+ }
+}
+#endif
+
void FastTextAutosizer::FingerprintMapper::add(const RenderObject* renderer, Fingerprint fingerprint)
{
+ remove(renderer);
+
m_fingerprints.set(renderer, fingerprint);
+#ifndef NDEBUG
+ assertMapsAreConsistent();
+#endif
}
void FastTextAutosizer::FingerprintMapper::addTentativeClusterRoot(const RenderBlock* block, Fingerprint fingerprint)
@@ -672,6 +694,9 @@ void FastTextAutosizer::FingerprintMapper::addTentativeClusterRoot(const RenderB
if (addResult.isNewEntry)
addResult.storedValue->value = adoptPtr(new BlockSet);
addResult.storedValue->value->add(block);
+#ifndef NDEBUG
+ assertMapsAreConsistent();
+#endif
}
void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer)
@@ -688,6 +713,9 @@ void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer)
blocks.remove(toRenderBlock(renderer));
if (blocks.isEmpty())
m_blocksForFingerprint.remove(blocksIter);
+#ifndef NDEBUG
+ assertMapsAreConsistent();
+#endif
}
FastTextAutosizer::Fingerprint FastTextAutosizer::FingerprintMapper::get(const RenderObject* renderer)
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698