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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/paint/DisplayItemClient.cpp

Issue 2150933002: Fix crash when removing contents from a document having multiple bodies (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutScrollbarPart.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/paint/DisplayItemClient.h" 5 #include "platform/graphics/paint/DisplayItemClient.h"
6 6
7 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 7 #if CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
8 #include "wtf/HashMap.h" 8 #include "wtf/HashMap.h"
9 #include "wtf/HashSet.h" 9 #include "wtf/HashSet.h"
10 #endif 10 #endif
(...skipping 17 matching lines...) Expand all
28 liveDisplayItemClients = new HashSet<const DisplayItemClient*>(); 28 liveDisplayItemClients = new HashSet<const DisplayItemClient*>();
29 liveDisplayItemClients->add(this); 29 liveDisplayItemClients->add(this);
30 } 30 }
31 31
32 DisplayItemClient::~DisplayItemClient() 32 DisplayItemClient::~DisplayItemClient()
33 { 33 {
34 if (displayItemClientsShouldKeepAlive) { 34 if (displayItemClientsShouldKeepAlive) {
35 for (auto& item : *displayItemClientsShouldKeepAlive) { 35 for (auto& item : *displayItemClientsShouldKeepAlive) {
36 CHECK(!item.value.contains(this)) 36 CHECK(!item.value.contains(this))
37 << "Short-lived DisplayItemClient: " << item.value.get(this) 37 << "Short-lived DisplayItemClient: " << item.value.get(this)
38 << ". See crbug.com/570030."; 38 << ". See crbug.com/609218.";
39 } 39 }
40 } 40 }
41 liveDisplayItemClients->remove(this); 41 liveDisplayItemClients->remove(this);
42 // In case this object is a subsequence owner. 42 // In case this object is a subsequence owner.
43 endShouldKeepAliveAllClients(this); 43 endShouldKeepAliveAllClients(this);
44 } 44 }
45 45
46 bool DisplayItemClient::isAlive() const 46 bool DisplayItemClient::isAlive() const
47 { 47 {
48 return liveDisplayItemClients && liveDisplayItemClients->contains(this); 48 return liveDisplayItemClients && liveDisplayItemClients->contains(this);
49 } 49 }
50 50
51 void DisplayItemClient::beginShouldKeepAlive(const void* owner) const 51 void DisplayItemClient::beginShouldKeepAlive(const void* owner) const
52 { 52 {
53 CHECK(isAlive()); 53 CHECK(isAlive());
54 if (!displayItemClientsShouldKeepAlive) 54 if (!displayItemClientsShouldKeepAlive)
55 displayItemClientsShouldKeepAlive = new HashMap<const void*, HashMap<con st DisplayItemClient*, String>>(); 55 displayItemClientsShouldKeepAlive = new HashMap<const void*, HashMap<con st DisplayItemClient*, String>>();
56 auto addResult = displayItemClientsShouldKeepAlive->add(owner, HashMap<const DisplayItemClient*, String>()).storedValue->value.add(this, ""); 56 auto addResult = displayItemClientsShouldKeepAlive->add(owner, HashMap<const DisplayItemClient*, String>()).storedValue->value.add(this, "");
57 if (addResult.isNewEntry) 57 if (addResult.isNewEntry)
58 addResult.storedValue->value = debugName(); 58 addResult.storedValue->value = debugName();
59 } 59 }
60 60
61 void DisplayItemClient::endShouldKeepAlive() const 61 void DisplayItemClient::endShouldKeepAlive() const
62 { 62 {
63 if (displayItemClientsShouldKeepAlive) { 63 if (displayItemClientsShouldKeepAlive) {
64 for (auto item : *displayItemClientsShouldKeepAlive) 64 for (auto& item : *displayItemClientsShouldKeepAlive)
65 item.value.remove(this); 65 item.value.remove(this);
66 } 66 }
67 } 67 }
68 68
69 void DisplayItemClient::endShouldKeepAliveAllClients(const void* owner) 69 void DisplayItemClient::endShouldKeepAliveAllClients(const void* owner)
70 { 70 {
71 if (displayItemClientsShouldKeepAlive) 71 if (displayItemClientsShouldKeepAlive)
72 displayItemClientsShouldKeepAlive->remove(owner); 72 displayItemClientsShouldKeepAlive->remove(owner);
73 } 73 }
74 74
75 void DisplayItemClient::endShouldKeepAliveAllClients() 75 void DisplayItemClient::endShouldKeepAliveAllClients()
76 { 76 {
77 delete displayItemClientsShouldKeepAlive; 77 delete displayItemClientsShouldKeepAlive;
78 displayItemClientsShouldKeepAlive = nullptr; 78 displayItemClientsShouldKeepAlive = nullptr;
79 } 79 }
80 80
81 #endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS 81 #endif // CHECK_DISPLAY_ITEM_CLIENT_ALIVENESS
82 82
83 } // namespace blink 83 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutScrollbarPart.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698