| 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 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 AtomicString fingerprint = m_fingerprintMapper.get(block); | 272 AtomicString fingerprint = m_fingerprintMapper.get(block); |
| 273 if (fingerprint.isNull()) | 273 if (fingerprint.isNull()) |
| 274 return 0; | 274 return 0; |
| 275 | 275 |
| 276 BlockSet* roots = &m_fingerprintMapper.getBlocks(fingerprint); | 276 BlockSet* roots = &m_fingerprintMapper.getBlocks(fingerprint); |
| 277 if (roots->size() < 2) | 277 if (roots->size() < 2) |
| 278 return 0; | 278 return 0; |
| 279 | 279 |
| 280 SuperclusterMap::AddResult addResult = m_superclusters.add(fingerprint, Pass
OwnPtr<Supercluster>()); | 280 SuperclusterMap::AddResult addResult = m_superclusters.add(fingerprint, Pass
OwnPtr<Supercluster>()); |
| 281 if (!addResult.isNewEntry) | 281 if (!addResult.isNewEntry) |
| 282 return addResult.iterator->value.get(); | 282 return addResult.storedValue->value.get(); |
| 283 | 283 |
| 284 Supercluster* supercluster = new Supercluster(roots); | 284 Supercluster* supercluster = new Supercluster(roots); |
| 285 addResult.iterator->value = adoptPtr(supercluster); | 285 addResult.storedValue->value = adoptPtr(supercluster); |
| 286 return supercluster; | 286 return supercluster; |
| 287 } | 287 } |
| 288 | 288 |
| 289 const RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks) | 289 const RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks) |
| 290 { | 290 { |
| 291 // Find the lowest common ancestor of blocks. | 291 // Find the lowest common ancestor of blocks. |
| 292 // Note: this could be improved to not be O(b*h) for b blocks and tree heigh
t h. | 292 // Note: this could be improved to not be O(b*h) for b blocks and tree heigh
t h. |
| 293 HashCountedSet<const RenderBlock*> ancestors; | 293 HashCountedSet<const RenderBlock*> ancestors; |
| 294 for (BlockSet::iterator it = blocks.begin(); it != blocks.end(); ++it) { | 294 for (BlockSet::iterator it = blocks.begin(); it != blocks.end(); ++it) { |
| 295 for (const RenderBlock* block = (*it); block; block = block->containingB
lock()) { | 295 for (const RenderBlock* block = (*it); block; block = block->containingB
lock()) { |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 ASSERT(!m_clusterStack.isEmpty()); | 495 ASSERT(!m_clusterStack.isEmpty()); |
| 496 return m_clusterStack.last().get(); | 496 return m_clusterStack.last().get(); |
| 497 } | 497 } |
| 498 | 498 |
| 499 void FastTextAutosizer::FingerprintMapper::add(const RenderBlock* block, AtomicS
tring fingerprint) | 499 void FastTextAutosizer::FingerprintMapper::add(const RenderBlock* block, AtomicS
tring fingerprint) |
| 500 { | 500 { |
| 501 m_fingerprints.set(block, fingerprint); | 501 m_fingerprints.set(block, fingerprint); |
| 502 | 502 |
| 503 ReverseFingerprintMap::AddResult addResult = m_blocksForFingerprint.add(fing
erprint, PassOwnPtr<BlockSet>()); | 503 ReverseFingerprintMap::AddResult addResult = m_blocksForFingerprint.add(fing
erprint, PassOwnPtr<BlockSet>()); |
| 504 if (addResult.isNewEntry) | 504 if (addResult.isNewEntry) |
| 505 addResult.iterator->value = adoptPtr(new BlockSet); | 505 addResult.storedValue->value = adoptPtr(new BlockSet); |
| 506 addResult.iterator->value->add(block); | 506 addResult.storedValue->value->add(block); |
| 507 } | 507 } |
| 508 | 508 |
| 509 void FastTextAutosizer::FingerprintMapper::remove(const RenderBlock* block) | 509 void FastTextAutosizer::FingerprintMapper::remove(const RenderBlock* block) |
| 510 { | 510 { |
| 511 AtomicString fingerprint = m_fingerprints.take(block); | 511 AtomicString fingerprint = m_fingerprints.take(block); |
| 512 if (fingerprint.isNull()) | 512 if (fingerprint.isNull()) |
| 513 return; | 513 return; |
| 514 | 514 |
| 515 ReverseFingerprintMap::iterator blocksIter = m_blocksForFingerprint.find(fin
gerprint); | 515 ReverseFingerprintMap::iterator blocksIter = m_blocksForFingerprint.find(fin
gerprint); |
| 516 BlockSet& blocks = *blocksIter->value; | 516 BlockSet& blocks = *blocksIter->value; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 530 } | 530 } |
| 531 | 531 |
| 532 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO
bject* current, const RenderObject* stayWithin) | 532 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO
bject* current, const RenderObject* stayWithin) |
| 533 { | 533 { |
| 534 if (current == stayWithin || !current->isRenderBlock()) | 534 if (current == stayWithin || !current->isRenderBlock()) |
| 535 return current->nextInPreOrder(stayWithin); | 535 return current->nextInPreOrder(stayWithin); |
| 536 return current->nextInPreOrderAfterChildren(stayWithin); | 536 return current->nextInPreOrderAfterChildren(stayWithin); |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace WebCore | 539 } // namespace WebCore |
| OLD | NEW |