OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 return; | 313 return; |
314 | 314 |
315 if (Fingerprint fingerprint = computeFingerprint(block)) | 315 if (Fingerprint fingerprint = computeFingerprint(block)) |
316 m_fingerprintMapper.addTentativeClusterRoot(block, fingerprint); | 316 m_fingerprintMapper.addTentativeClusterRoot(block, fingerprint); |
317 } | 317 } |
318 | 318 |
319 void FastTextAutosizer::destroy(const RenderBlock* block) | 319 void FastTextAutosizer::destroy(const RenderBlock* block) |
320 { | 320 { |
321 if (!m_pageInfo.m_settingEnabled) | 321 if (!m_pageInfo.m_settingEnabled) |
322 return; | 322 return; |
| 323 |
323 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); | 324 ASSERT(!m_blocksThatHaveBegunLayout.contains(block)); |
324 | 325 |
325 m_fingerprintMapper.remove(block); | 326 if (m_fingerprintMapper.remove(block) && m_firstBlockToBeginLayout) { |
| 327 // RenderBlock with a fingerprint was destroyed during layout. |
| 328 // Clear the cluster stack and the supercluster map to avoid stale point
ers. |
| 329 // Speculative fix for http://crbug.com/369485. |
| 330 m_firstBlockToBeginLayout = 0; |
| 331 m_clusterStack.clear(); |
| 332 m_superclusters.clear(); |
| 333 } |
326 } | 334 } |
327 | 335 |
328 FastTextAutosizer::BeginLayoutBehavior FastTextAutosizer::prepareForLayout(const
RenderBlock* block) | 336 FastTextAutosizer::BeginLayoutBehavior FastTextAutosizer::prepareForLayout(const
RenderBlock* block) |
329 { | 337 { |
330 #ifndef NDEBUG | 338 #ifndef NDEBUG |
331 m_blocksThatHaveBegunLayout.add(block); | 339 m_blocksThatHaveBegunLayout.add(block); |
332 #endif | 340 #endif |
333 | 341 |
334 if (!m_firstBlockToBeginLayout) { | 342 if (!m_firstBlockToBeginLayout) { |
335 m_firstBlockToBeginLayout = block; | 343 m_firstBlockToBeginLayout = block; |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 | 1059 |
1052 ReverseFingerprintMap::AddResult addResult = m_blocksForFingerprint.add(fing
erprint, PassOwnPtr<BlockSet>()); | 1060 ReverseFingerprintMap::AddResult addResult = m_blocksForFingerprint.add(fing
erprint, PassOwnPtr<BlockSet>()); |
1053 if (addResult.isNewEntry) | 1061 if (addResult.isNewEntry) |
1054 addResult.storedValue->value = adoptPtr(new BlockSet); | 1062 addResult.storedValue->value = adoptPtr(new BlockSet); |
1055 addResult.storedValue->value->add(block); | 1063 addResult.storedValue->value->add(block); |
1056 #ifndef NDEBUG | 1064 #ifndef NDEBUG |
1057 assertMapsAreConsistent(); | 1065 assertMapsAreConsistent(); |
1058 #endif | 1066 #endif |
1059 } | 1067 } |
1060 | 1068 |
1061 void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer) | 1069 bool FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer) |
1062 { | 1070 { |
1063 Fingerprint fingerprint = m_fingerprints.take(renderer); | 1071 Fingerprint fingerprint = m_fingerprints.take(renderer); |
1064 if (!fingerprint || !renderer->isRenderBlock()) | 1072 if (!fingerprint || !renderer->isRenderBlock()) |
1065 return; | 1073 return false; |
1066 | 1074 |
1067 ReverseFingerprintMap::iterator blocksIter = m_blocksForFingerprint.find(fin
gerprint); | 1075 ReverseFingerprintMap::iterator blocksIter = m_blocksForFingerprint.find(fin
gerprint); |
1068 if (blocksIter == m_blocksForFingerprint.end()) | 1076 if (blocksIter == m_blocksForFingerprint.end()) |
1069 return; | 1077 return false; |
1070 | 1078 |
1071 BlockSet& blocks = *blocksIter->value; | 1079 BlockSet& blocks = *blocksIter->value; |
1072 blocks.remove(toRenderBlock(renderer)); | 1080 blocks.remove(toRenderBlock(renderer)); |
1073 if (blocks.isEmpty()) | 1081 if (blocks.isEmpty()) |
1074 m_blocksForFingerprint.remove(blocksIter); | 1082 m_blocksForFingerprint.remove(blocksIter); |
1075 #ifndef NDEBUG | 1083 #ifndef NDEBUG |
1076 assertMapsAreConsistent(); | 1084 assertMapsAreConsistent(); |
1077 #endif | 1085 #endif |
| 1086 return true; |
1078 } | 1087 } |
1079 | 1088 |
1080 FastTextAutosizer::Fingerprint FastTextAutosizer::FingerprintMapper::get(const R
enderObject* renderer) | 1089 FastTextAutosizer::Fingerprint FastTextAutosizer::FingerprintMapper::get(const R
enderObject* renderer) |
1081 { | 1090 { |
1082 return m_fingerprints.get(renderer); | 1091 return m_fingerprints.get(renderer); |
1083 } | 1092 } |
1084 | 1093 |
1085 FastTextAutosizer::BlockSet& FastTextAutosizer::FingerprintMapper::getTentativeC
lusterRoots(Fingerprint fingerprint) | 1094 FastTextAutosizer::BlockSet& FastTextAutosizer::FingerprintMapper::getTentativeC
lusterRoots(Fingerprint fingerprint) |
1086 { | 1095 { |
1087 return *m_blocksForFingerprint.get(fingerprint); | 1096 return *m_blocksForFingerprint.get(fingerprint); |
(...skipping 30 matching lines...) Expand all Loading... |
1118 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() | 1127 FastTextAutosizer::DeferUpdatePageInfo::~DeferUpdatePageInfo() |
1119 { | 1128 { |
1120 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto
sizer()) { | 1129 if (FastTextAutosizer* textAutosizer = m_mainFrame->document()->fastTextAuto
sizer()) { |
1121 ASSERT(textAutosizer->m_updatePageInfoDeferred); | 1130 ASSERT(textAutosizer->m_updatePageInfoDeferred); |
1122 textAutosizer->m_updatePageInfoDeferred = false; | 1131 textAutosizer->m_updatePageInfoDeferred = false; |
1123 textAutosizer->updatePageInfoInAllFrames(); | 1132 textAutosizer->updatePageInfoInAllFrames(); |
1124 } | 1133 } |
1125 } | 1134 } |
1126 | 1135 |
1127 } // namespace WebCore | 1136 } // namespace WebCore |
OLD | NEW |