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

Side by Side Diff: third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.cpp

Issue 2190693002: [merge to M53] Make sure Widget::dispose() respects UpdateSuspendScope. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 using WidgetSet = HeapHashSet<Member<Widget>>; 48 using WidgetSet = HeapHashSet<Member<Widget>>;
49 static WidgetSet& widgetsPendingTemporaryRemovalFromParent() 49 static WidgetSet& widgetsPendingTemporaryRemovalFromParent()
50 { 50 {
51 // Widgets in this set will not leak because it will be cleared in 51 // Widgets in this set will not leak because it will be cleared in
52 // HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOpera tions. 52 // HTMLFrameOwnerElement::UpdateSuspendScope::performDeferredWidgetTreeOpera tions.
53 DEFINE_STATIC_LOCAL(WidgetSet, set, (new WidgetSet)); 53 DEFINE_STATIC_LOCAL(WidgetSet, set, (new WidgetSet));
54 return set; 54 return set;
55 } 55 }
56 56
57 static WidgetSet& widgetsPendingDispose()
58 {
59 DEFINE_STATIC_LOCAL(WidgetSet, set, (new WidgetSet));
60 return set;
61 }
62
57 SubframeLoadingDisabler::SubtreeRootSet& SubframeLoadingDisabler::disabledSubtre eRoots() 63 SubframeLoadingDisabler::SubtreeRootSet& SubframeLoadingDisabler::disabledSubtre eRoots()
58 { 64 {
59 DEFINE_STATIC_LOCAL(SubtreeRootSet, nodes, (new SubtreeRootSet)); 65 DEFINE_STATIC_LOCAL(SubtreeRootSet, nodes, (new SubtreeRootSet));
60 return nodes; 66 return nodes;
61 } 67 }
62 68
63 static unsigned s_updateSuspendCount = 0; 69 static unsigned s_updateSuspendCount = 0;
64 70
65 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope() 71 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope()
66 { 72 {
(...skipping 11 matching lines...) Expand all
78 if (newParent != currentParent) { 84 if (newParent != currentParent) {
79 if (currentParent) 85 if (currentParent)
80 currentParent->removeChild(child); 86 currentParent->removeChild(child);
81 if (newParent) 87 if (newParent)
82 newParent->addChild(child); 88 newParent->addChild(child);
83 if (currentParent && !newParent) 89 if (currentParent && !newParent)
84 child->dispose(); 90 child->dispose();
85 } 91 }
86 } 92 }
87 93
88 WidgetSet set; 94 {
89 widgetsPendingTemporaryRemovalFromParent().swap(set); 95 WidgetSet set;
90 for (const auto& widget : set) { 96 widgetsPendingTemporaryRemovalFromParent().swap(set);
91 FrameView* currentParent = toFrameView(widget->parent()); 97 for (const auto& widget : set) {
92 if (currentParent) 98 FrameView* currentParent = toFrameView(widget->parent());
93 currentParent->removeChild(widget.get()); 99 if (currentParent)
100 currentParent->removeChild(widget.get());
101 }
102 }
103
104 {
105 WidgetSet set;
106 widgetsPendingDispose().swap(set);
107 for (const auto& widget : set) {
108 widget->dispose();
109 }
94 } 110 }
95 } 111 }
96 112
97 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope() 113 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope()
98 { 114 {
99 ASSERT(s_updateSuspendCount > 0); 115 ASSERT(s_updateSuspendCount > 0);
100 if (s_updateSuspendCount == 1) 116 if (s_updateSuspendCount == 1)
101 performDeferredWidgetTreeOperations(); 117 performDeferredWidgetTreeOperations();
102 --s_updateSuspendCount; 118 --s_updateSuspendCount;
103 } 119 }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // the subframe hasn't been created yet. 219 // the subframe hasn't been created yet.
204 if (contentFrame()) 220 if (contentFrame())
205 document().frame()->loader().client()->didChangeSandboxFlags(contentFram e(), flags); 221 document().frame()->loader().client()->didChangeSandboxFlags(contentFram e(), flags);
206 } 222 }
207 223
208 bool HTMLFrameOwnerElement::isKeyboardFocusable() const 224 bool HTMLFrameOwnerElement::isKeyboardFocusable() const
209 { 225 {
210 return m_contentFrame && HTMLElement::isKeyboardFocusable(); 226 return m_contentFrame && HTMLElement::isKeyboardFocusable();
211 } 227 }
212 228
229 void HTMLFrameOwnerElement::disposeWidgetSoon(Widget* widget)
230 {
231 if (s_updateSuspendCount) {
232 widgetsPendingDispose().add(widget);
233 return;
234 }
235 widget->dispose();
236 }
237
213 void HTMLFrameOwnerElement::dispatchLoad() 238 void HTMLFrameOwnerElement::dispatchLoad()
214 { 239 {
215 dispatchScopedEvent(Event::create(EventTypeNames::load)); 240 dispatchScopedEvent(Event::create(EventTypeNames::load));
216 } 241 }
217 242
218 const WebVector<WebPermissionType>& HTMLFrameOwnerElement::delegatedPermissions( ) const 243 const WebVector<WebPermissionType>& HTMLFrameOwnerElement::delegatedPermissions( ) const
219 { 244 {
220 DEFINE_STATIC_LOCAL(WebVector<WebPermissionType>, permissions, ()); 245 DEFINE_STATIC_LOCAL(WebVector<WebPermissionType>, permissions, ());
221 return permissions; 246 return permissions;
222 } 247 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 DEFINE_TRACE(HTMLFrameOwnerElement) 334 DEFINE_TRACE(HTMLFrameOwnerElement)
310 { 335 {
311 visitor->trace(m_contentFrame); 336 visitor->trace(m_contentFrame);
312 visitor->trace(m_widget); 337 visitor->trace(m_widget);
313 HTMLElement::trace(visitor); 338 HTMLElement::trace(visitor);
314 FrameOwner::trace(visitor); 339 FrameOwner::trace(visitor);
315 } 340 }
316 341
317 342
318 } // namespace blink 343 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFrameOwnerElement.h ('k') | third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698