Changeset 235537 in webkit
- Timestamp:
- Aug 30, 2018, 9:27:44 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 3 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/css/counters/crash-when-cloning-body-expected.txt (added)
-
LayoutTests/fast/css/counters/crash-when-cloning-body.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/rendering/RenderCounter.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r235523 r235537 1 2018-08-30 Zalan Bujtas <zalan@apple.com> 2 3 CounterMaps should hold a unique_ptr of CounterMap. 4 https://bugs.webkit.org/show_bug.cgi?id=189174 5 <rdar://problem/43686458> 6 7 Reviewed by Ryosuke Niwa. 8 9 * fast/css/counters/crash-when-cloning-body-expected.txt: Added. 10 * fast/css/counters/crash-when-cloning-body.html: Added. 11 1 12 2018-08-30 Truitt Savell <tsavell@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r235536 r235537 1 2018-08-30 Zalan Bujtas <zalan@apple.com> 2 3 CounterMaps should hold a unique_ptr of CounterMap. 4 https://bugs.webkit.org/show_bug.cgi?id=189174 5 <rdar://problem/43686458> 6 7 Reviewed by Ryosuke Niwa. 8 9 In certain cases calls to CounterMaps might lead to unexpected deletion of the CounterMap object. 10 11 Test: fast/css/counters/crash-when-cloning-body.html 12 13 * rendering/RenderCounter.cpp: 14 (WebCore::makeCounterNode): 15 (WebCore::destroyCounterNodeWithoutMapRemoval): 16 (WebCore::RenderCounter::destroyCounterNodes): 17 (WebCore::RenderCounter::destroyCounterNode): 18 (WebCore::updateCounters): 19 (showCounterRendererTree): 20 1 21 2018-08-30 Ross Kirsling <ross.kirsling@sony.com> 2 22 -
trunk/Source/WebCore/rendering/RenderCounter.cpp
r232178 r235537 48 48 49 49 using CounterMap = HashMap<AtomicString, Ref<CounterNode>>; 50 using CounterMaps = HashMap<const RenderElement*, CounterMap>;50 using CounterMaps = HashMap<const RenderElement*, std::unique_ptr<CounterMap>>; 51 51 52 52 static CounterNode* makeCounterNode(RenderElement&, const AtomicString& identifier, bool alwaysCreateCounter); … … 297 297 if (renderer.hasCounterNodeMap()) { 298 298 ASSERT(counterMaps().contains(&renderer)); 299 if (auto* node = counterMaps().find(&renderer)->value .get(identifier))299 if (auto* node = counterMaps().find(&renderer)->value->get(identifier)) 300 300 return node; 301 301 } … … 313 313 place.parent->insertAfter(newNode, place.previousSibling.get(), identifier); 314 314 315 maps.add(&renderer, CounterMap { }).iterator->value.add(identifier, newNode.copyRef());315 maps.add(&renderer, std::make_unique<CounterMap>()).iterator->value->add(identifier, newNode.copyRef()); 316 316 renderer.setHasCounterNodeMap(true); 317 317 … … 327 327 if (!currentRenderer->hasCounterNodeMap()) 328 328 continue; 329 auto* currentCounter = maps.find(currentRenderer)->value .get(identifier);329 auto* currentCounter = maps.find(currentRenderer)->value->get(identifier); 330 330 if (!currentCounter) 331 331 continue; … … 437 437 previous = child->previousInPreOrder(); 438 438 child->parent()->removeChild(*child); 439 ASSERT(counterMaps().find(&child->owner())->value .get(identifier) == child);440 counterMaps().find(&child->owner())->value .remove(identifier);439 ASSERT(counterMaps().find(&child->owner())->value->get(identifier) == child); 440 counterMaps().find(&child->owner())->value->remove(identifier); 441 441 } 442 442 if (auto* parent = node.parent()) … … 449 449 auto& maps = counterMaps(); 450 450 ASSERT(maps.contains(&owner)); 451 for (auto& keyValue : maps.take(&owner)) 452 destroyCounterNodeWithoutMapRemoval(keyValue.key, keyValue.value); 451 auto counterMap = maps.take(&owner); 452 for (auto& counterMapEntry : *counterMap) 453 destroyCounterNodeWithoutMapRemoval(counterMapEntry.key, counterMapEntry.value); 453 454 owner.setHasCounterNodeMap(false); 454 455 } … … 459 460 if (map == counterMaps().end()) 460 461 return; 461 auto node = map->value .take(identifier);462 auto node = map->value->take(identifier); 462 463 if (!node) 463 464 return; … … 500 501 } 501 502 ASSERT(counterMaps().contains(&renderer)); 502 auto & counterMap = counterMaps().find(&renderer)->value;503 auto* counterMap = counterMaps().find(&renderer)->value.get(); 503 504 for (auto& key : directiveMap->keys()) { 504 RefPtr<CounterNode> node = counterMap .get(key);505 RefPtr<CounterNode> node = counterMap->get(key); 505 506 if (!node) { 506 507 makeCounterNode(renderer, key, false); … … 508 509 } 509 510 auto place = findPlaceForCounter(renderer, key, node->hasResetType()); 510 if (node != counterMap .get(key))511 if (node != counterMap->get(key)) 511 512 continue; 512 513 CounterNode* parent = node->parent(); … … 602 603 current, current->node(), current->parent(), current->previousSibling(), 603 604 current->nextSibling(), downcast<WebCore::RenderElement>(*current).hasCounterNodeMap() ? 604 counterName ? WebCore::counterMaps().find(downcast<WebCore::RenderElement>(current))->value .get(identifier) : (WebCore::CounterNode*)1 : (WebCore::CounterNode*)0);605 counterName ? WebCore::counterMaps().find(downcast<WebCore::RenderElement>(current))->value->get(identifier) : (WebCore::CounterNode*)1 : (WebCore::CounterNode*)0); 605 606 } 606 607 fflush(stderr);
Note:
See TracChangeset
for help on using the changeset viewer.