Index: Source/core/rendering/FastTextAutosizer.cpp |
diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp |
index 2dea427fd5d3e084551eb6a921d051a28f0eab79..4c3e2738906531d38b1cf5358a97d2c82d75669a 100644 |
--- a/Source/core/rendering/FastTextAutosizer.cpp |
+++ b/Source/core/rendering/FastTextAutosizer.cpp |
@@ -320,9 +320,17 @@ void FastTextAutosizer::destroy(const RenderBlock* block) |
{ |
if (!m_pageInfo.m_settingEnabled) |
return; |
+ |
ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); |
- m_fingerprintMapper.remove(block); |
+ if (m_fingerprintMapper.remove(block) && m_firstBlockToBeginLayout) { |
+ // RenderBlock with a fingerprint was destroyed during layout. |
+ // Clear the cluster stack and the supercluster map to avoid stale pointers. |
+ // Speculative fix for http://crbug.com/369485. |
+ m_firstBlockToBeginLayout = 0; |
+ m_clusterStack.clear(); |
+ m_superclusters.clear(); |
+ } |
} |
FastTextAutosizer::BeginLayoutBehavior FastTextAutosizer::prepareForLayout(const RenderBlock* block) |
@@ -1058,15 +1066,15 @@ void FastTextAutosizer::FingerprintMapper::addTentativeClusterRoot(const RenderB |
#endif |
} |
-void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer) |
+bool FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer) |
{ |
Fingerprint fingerprint = m_fingerprints.take(renderer); |
if (!fingerprint || !renderer->isRenderBlock()) |
- return; |
+ return false; |
ReverseFingerprintMap::iterator blocksIter = m_blocksForFingerprint.find(fingerprint); |
if (blocksIter == m_blocksForFingerprint.end()) |
- return; |
+ return false; |
BlockSet& blocks = *blocksIter->value; |
blocks.remove(toRenderBlock(renderer)); |
@@ -1075,6 +1083,7 @@ void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer) |
#ifndef NDEBUG |
assertMapsAreConsistent(); |
#endif |
+ return true; |
} |
FastTextAutosizer::Fingerprint FastTextAutosizer::FingerprintMapper::get(const RenderObject* renderer) |