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

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

Issue 2871453002: Delete widget tree (FrameView::parent_) (Closed)
Patch Set: Remove deferred state Created 3 years, 7 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 70
71 static unsigned g_update_suspend_count = 0; 71 static unsigned g_update_suspend_count = 0;
72 72
73 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope() { 73 HTMLFrameOwnerElement::UpdateSuspendScope::UpdateSuspendScope() {
74 ++g_update_suspend_count; 74 ++g_update_suspend_count;
75 } 75 }
76 76
77 void HTMLFrameOwnerElement::UpdateSuspendScope:: 77 void HTMLFrameOwnerElement::UpdateSuspendScope::
78 PerformDeferredWidgetTreeOperations() { 78 PerformDeferredWidgetTreeOperations() {
79 VLOG(1) << "Performing deferred operations NewParent.size="
80 << FrameOrPluginNewParentMap().size() << ", TempRemoval.size="
81 << FrameOrPluginsPendingTemporaryRemovalFromParent().size()
82 << ", Dispose.size=" << FrameOrPluginsPendingDispose().size();
79 FrameOrPluginToParentMap map; 83 FrameOrPluginToParentMap map;
80 FrameOrPluginNewParentMap().swap(map); 84 FrameOrPluginNewParentMap().swap(map);
81 for (const auto& entry : map) { 85 for (const auto& entry : map) {
82 FrameOrPlugin* child = entry.key; 86 FrameOrPlugin* child = entry.key;
83 FrameView* current_parent = child->Parent(); 87 FrameView* current_parent = child->Parent();
84 FrameView* new_parent = entry.value; 88 FrameView* new_parent = entry.value;
85 if (new_parent != current_parent) { 89 if (new_parent != current_parent) {
86 if (current_parent) 90 if (current_parent)
87 current_parent->RemoveChild(child); 91 current_parent->RemoveChild(child);
88 if (new_parent) { 92 if (new_parent) {
(...skipping 21 matching lines...) Expand all
110 114
111 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope() { 115 HTMLFrameOwnerElement::UpdateSuspendScope::~UpdateSuspendScope() {
112 DCHECK_GT(g_update_suspend_count, 0u); 116 DCHECK_GT(g_update_suspend_count, 0u);
113 if (g_update_suspend_count == 1) 117 if (g_update_suspend_count == 1)
114 PerformDeferredWidgetTreeOperations(); 118 PerformDeferredWidgetTreeOperations();
115 --g_update_suspend_count; 119 --g_update_suspend_count;
116 } 120 }
117 121
118 // Unlike MoveFrameOrPluginToParentSoon, this will not call dispose. 122 // Unlike MoveFrameOrPluginToParentSoon, this will not call dispose.
119 void TemporarilyRemoveFrameOrPluginFromParentSoon(FrameOrPlugin* child) { 123 void TemporarilyRemoveFrameOrPluginFromParentSoon(FrameOrPlugin* child) {
124 // child->SetFrameOrPluginState(FrameOrPlugin::kDeferred);
120 if (g_update_suspend_count) { 125 if (g_update_suspend_count) {
126 VLOG(1) << "Defered temp remove child=" << child;
127 if (VLOG_IS_ON(2))
128 base::debug::StackTrace(10).Print();
121 FrameOrPluginsPendingTemporaryRemovalFromParent().insert(child); 129 FrameOrPluginsPendingTemporaryRemovalFromParent().insert(child);
122 } else { 130 } else {
123 if (child->Parent()) 131 if (child->Parent())
124 child->Parent()->RemoveChild(child); 132 child->Parent()->RemoveChild(child);
125 } 133 }
126 } 134 }
127 135
128 void MoveFrameOrPluginToParentSoon(FrameOrPlugin* child, FrameView* parent) { 136 void MoveFrameOrPluginToParentSoon(FrameOrPlugin* child, FrameView* parent) {
137 // child->SetFrameOrPluginState(FrameOrPlugin::kDeferred);
129 if (!g_update_suspend_count) { 138 if (!g_update_suspend_count) {
130 if (parent) { 139 if (parent) {
131 DCHECK(child != parent && !child->Parent()); 140 DCHECK(child != parent && !child->Parent());
132 child->SetParent(parent); 141 child->SetParent(parent);
133 } else if (child->Parent()) { 142 } else if (child->Parent()) {
134 child->Parent()->RemoveChild(child); 143 child->Parent()->RemoveChild(child);
135 child->Dispose(); 144 child->Dispose();
136 } 145 }
137 return; 146 return;
138 } 147 }
148 VLOG(1) << "Deferred New Parent child=" << child << ", parent=" << parent;
149 if (VLOG_IS_ON(2))
150 base::debug::StackTrace(10).Print();
139 FrameOrPluginNewParentMap().Set(child, parent); 151 FrameOrPluginNewParentMap().Set(child, parent);
140 } 152 }
141 153
142 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tag_name, 154 HTMLFrameOwnerElement::HTMLFrameOwnerElement(const QualifiedName& tag_name,
143 Document& document) 155 Document& document)
144 : HTMLElement(tag_name, document), 156 : HTMLElement(tag_name, document),
145 content_frame_(nullptr), 157 content_frame_(nullptr),
146 widget_(nullptr), 158 widget_(nullptr),
147 sandbox_flags_(kSandboxNone) {} 159 sandbox_flags_(kSandboxNone) {}
148 160
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 281
270 Document* HTMLFrameOwnerElement::getSVGDocument( 282 Document* HTMLFrameOwnerElement::getSVGDocument(
271 ExceptionState& exception_state) const { 283 ExceptionState& exception_state) const {
272 Document* doc = contentDocument(); 284 Document* doc = contentDocument();
273 if (doc && doc->IsSVGDocument()) 285 if (doc && doc->IsSVGDocument())
274 return doc; 286 return doc;
275 return nullptr; 287 return nullptr;
276 } 288 }
277 289
278 void HTMLFrameOwnerElement::SetWidget(FrameOrPlugin* frame_or_plugin) { 290 void HTMLFrameOwnerElement::SetWidget(FrameOrPlugin* frame_or_plugin) {
291 VLOG(1) << "SetWidget old=" << widget_ << ", new=" << frame_or_plugin
292 << ", old parent=" << (!widget_ ? -1 : widget_ && widget_->Parent())
293 << ", count=" << g_update_suspend_count;
279 if (frame_or_plugin == widget_) 294 if (frame_or_plugin == widget_)
280 return; 295 return;
281 296
282 Document* doc = contentDocument(); 297 Document* doc = contentDocument();
283 if (doc && doc->GetFrame()) { 298 if (doc && doc->GetFrame()) {
284 bool will_be_display_none = !frame_or_plugin; 299 bool will_be_display_none = !frame_or_plugin;
285 if (IsDisplayNone() != will_be_display_none) { 300 if (IsDisplayNone() != will_be_display_none) {
286 doc->WillChangeFrameOwnerProperties( 301 doc->WillChangeFrameOwnerProperties(
287 MarginWidth(), MarginHeight(), ScrollingMode(), will_be_display_none); 302 MarginWidth(), MarginHeight(), ScrollingMode(), will_be_display_none);
288 } 303 }
289 } 304 }
290 305
291 if (widget_) { 306 if (widget_) {
292 if (widget_->Parent()) 307 if (widget_->Parent())
293 MoveFrameOrPluginToParentSoon(widget_, nullptr); 308 MoveFrameOrPluginToParentSoon(widget_, nullptr);
294 } 309 }
295 310
296 widget_ = frame_or_plugin; 311 widget_ = frame_or_plugin;
297 FrameOwnerPropertiesChanged(); 312 FrameOwnerPropertiesChanged();
298 313
299 LayoutPart* layout_part = ToLayoutPart(GetLayoutObject()); 314 LayoutPart* layout_part = ToLayoutPart(GetLayoutObject());
300 LayoutPartItem layout_part_item = LayoutPartItem(layout_part); 315 LayoutPartItem layout_part_item = LayoutPartItem(layout_part);
301 if (layout_part_item.IsNull()) 316 if (layout_part_item.IsNull()) {
317 VLOG(1) << "SetWidget new=" << frame_or_plugin << ", parent=0";
302 return; 318 return;
319 }
303 320
304 if (widget_) { 321 if (widget_) {
305 layout_part_item.UpdateOnWidgetChange(); 322 layout_part_item.UpdateOnWidgetChange();
306 323
307 DCHECK_EQ(GetDocument().View(), layout_part_item.GetFrameView()); 324 DCHECK_EQ(GetDocument().View(), layout_part_item.GetFrameView());
308 DCHECK(layout_part_item.GetFrameView()); 325 DCHECK(layout_part_item.GetFrameView());
326 VLOG(1) << "SetWidget new=" << frame_or_plugin
327 << ", parent=" << layout_part_item.GetFrameView();
309 MoveFrameOrPluginToParentSoon(widget_, layout_part_item.GetFrameView()); 328 MoveFrameOrPluginToParentSoon(widget_, layout_part_item.GetFrameView());
310 } 329 }
311 330
312 if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache()) 331 if (AXObjectCache* cache = GetDocument().ExistingAXObjectCache())
313 cache->ChildrenChanged(layout_part); 332 cache->ChildrenChanged(layout_part);
314 } 333 }
315 334
316 FrameOrPlugin* HTMLFrameOwnerElement::ReleaseWidget() { 335 FrameOrPlugin* HTMLFrameOwnerElement::ReleaseWidget() {
317 if (!widget_) 336 if (!widget_)
318 return nullptr; 337 return nullptr;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 } 384 }
366 385
367 DEFINE_TRACE(HTMLFrameOwnerElement) { 386 DEFINE_TRACE(HTMLFrameOwnerElement) {
368 visitor->Trace(content_frame_); 387 visitor->Trace(content_frame_);
369 visitor->Trace(widget_); 388 visitor->Trace(widget_);
370 HTMLElement::Trace(visitor); 389 HTMLElement::Trace(visitor);
371 FrameOwner::Trace(visitor); 390 FrameOwner::Trace(visitor);
372 } 391 }
373 392
374 } // namespace blink 393 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/RemoteFrameView.cpp ('k') | third_party/WebKit/Source/core/plugins/PluginView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698