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: Source/core/frame/LocalFrame.cpp

Issue 603193005: Move the Widget hierarchy to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Switch LocalFrame::m_pluginElements rep to HashSet<HTMLPlugInElement*> Created 6 years, 2 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) 1998, 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
3 * 1999 Lars Knoll <knoll@kde.org> 3 * 1999 Lars Knoll <knoll@kde.org>
4 * 1999 Antti Koivisto <koivisto@kde.org> 4 * 1999 Antti Koivisto <koivisto@kde.org>
5 * 2000 Simon Hausmann <hausmann@kde.org> 5 * 2000 Simon Hausmann <hausmann@kde.org>
6 * 2000 Stefan Schimanski <1Stein@gmx.de> 6 * 2000 Stefan Schimanski <1Stein@gmx.de>
7 * 2001 George Staikos <staikos@kde.org> 7 * 2001 George Staikos <staikos@kde.org>
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com>
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
(...skipping 30 matching lines...) Expand all
41 #include "core/events/Event.h" 41 #include "core/events/Event.h"
42 #include "core/fetch/ResourceFetcher.h" 42 #include "core/fetch/ResourceFetcher.h"
43 #include "core/frame/EventHandlerRegistry.h" 43 #include "core/frame/EventHandlerRegistry.h"
44 #include "core/frame/FrameConsole.h" 44 #include "core/frame/FrameConsole.h"
45 #include "core/frame/FrameDestructionObserver.h" 45 #include "core/frame/FrameDestructionObserver.h"
46 #include "core/frame/FrameHost.h" 46 #include "core/frame/FrameHost.h"
47 #include "core/frame/FrameView.h" 47 #include "core/frame/FrameView.h"
48 #include "core/frame/LocalDOMWindow.h" 48 #include "core/frame/LocalDOMWindow.h"
49 #include "core/frame/Settings.h" 49 #include "core/frame/Settings.h"
50 #include "core/html/HTMLFrameElementBase.h" 50 #include "core/html/HTMLFrameElementBase.h"
51 #include "core/html/HTMLPlugInElement.h"
51 #include "core/inspector/ConsoleMessageStorage.h" 52 #include "core/inspector/ConsoleMessageStorage.h"
52 #include "core/inspector/InspectorInstrumentation.h" 53 #include "core/inspector/InspectorInstrumentation.h"
53 #include "core/loader/FrameLoaderClient.h" 54 #include "core/loader/FrameLoaderClient.h"
54 #include "core/page/Chrome.h" 55 #include "core/page/Chrome.h"
55 #include "core/page/EventHandler.h" 56 #include "core/page/EventHandler.h"
56 #include "core/page/FocusController.h" 57 #include "core/page/FocusController.h"
57 #include "core/page/Page.h" 58 #include "core/page/Page.h"
58 #include "core/page/scrolling/ScrollingCoordinator.h" 59 #include "core/page/scrolling/ScrollingCoordinator.h"
59 #include "core/rendering/HitTestResult.h" 60 #include "core/rendering/HitTestResult.h"
60 #include "core/rendering/RenderLayer.h" 61 #include "core/rendering/RenderLayer.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 (*it)->frameDestroyed(); 139 (*it)->frameDestroyed();
139 #endif 140 #endif
140 } 141 }
141 142
142 void LocalFrame::trace(Visitor* visitor) 143 void LocalFrame::trace(Visitor* visitor)
143 { 144 {
144 #if ENABLE(OILPAN) 145 #if ENABLE(OILPAN)
145 visitor->trace(m_destructionObservers); 146 visitor->trace(m_destructionObservers);
146 visitor->trace(m_loader); 147 visitor->trace(m_loader);
147 visitor->trace(m_navigationScheduler); 148 visitor->trace(m_navigationScheduler);
149 visitor->trace(m_view);
148 visitor->trace(m_pagePopupOwner); 150 visitor->trace(m_pagePopupOwner);
149 visitor->trace(m_script); 151 visitor->trace(m_script);
150 visitor->trace(m_editor); 152 visitor->trace(m_editor);
151 visitor->trace(m_spellChecker); 153 visitor->trace(m_spellChecker);
152 visitor->trace(m_selection); 154 visitor->trace(m_selection);
153 visitor->trace(m_eventHandler); 155 visitor->trace(m_eventHandler);
154 visitor->trace(m_console); 156 visitor->trace(m_console);
155 visitor->trace(m_inputMethodController); 157 visitor->trace(m_inputMethodController);
158 visitor->registerWeakMembers<LocalFrame, &LocalFrame::clearWeakMembers>(this );
156 HeapSupplementable<LocalFrame>::trace(visitor); 159 HeapSupplementable<LocalFrame>::trace(visitor);
157 #endif 160 #endif
158 Frame::trace(visitor); 161 Frame::trace(visitor);
159 } 162 }
160 163
164 #if ENABLE(OILPAN)
165 void LocalFrame::clearWeakMembers(Visitor* visitor)
166 {
167 Vector<HTMLPlugInElement*> deadPlugins;
168 for (HashSet<HTMLPlugInElement*>::const_iterator it = m_pluginElements.begin (); it != m_pluginElements.end(); ++it) {
169 if (!visitor->isAlive(*it)) {
170 (*it)->shouldDisposePlugin();
171 deadPlugins.append(*it);
172 }
173 }
174 for (unsigned i = 0; i < deadPlugins.size(); ++i)
175 m_pluginElements.remove(deadPlugins[i]);
176 }
177 #endif
178
161 void LocalFrame::navigate(Document& originDocument, const KURL& url, bool lockBa ckForwardList) 179 void LocalFrame::navigate(Document& originDocument, const KURL& url, bool lockBa ckForwardList)
162 { 180 {
163 m_navigationScheduler.scheduleLocationChange(&originDocument, url.string(), lockBackForwardList); 181 m_navigationScheduler.scheduleLocationChange(&originDocument, url.string(), lockBackForwardList);
164 } 182 }
165 183
166 void LocalFrame::detach() 184 void LocalFrame::detach()
167 { 185 {
168 // A lot of the following steps can result in the current frame being 186 // A lot of the following steps can result in the current frame being
169 // detached, so protect a reference to it. 187 // detached, so protect a reference to it.
170 RefPtrWillBeRawPtr<LocalFrame> protect(this); 188 RefPtrWillBeRawPtr<LocalFrame> protect(this);
(...skipping 24 matching lines...) Expand all
195 { 213 {
196 // We detach the FrameView's custom scroll bars as early as 214 // We detach the FrameView's custom scroll bars as early as
197 // possible to prevent m_doc->detach() from messing with the view 215 // possible to prevent m_doc->detach() from messing with the view
198 // such that its scroll bars won't be torn down. 216 // such that its scroll bars won't be torn down.
199 // 217 //
200 // FIXME: We should revisit this. 218 // FIXME: We should revisit this.
201 if (m_view) 219 if (m_view)
202 m_view->prepareForDetach(); 220 m_view->prepareForDetach();
203 } 221 }
204 222
205 void LocalFrame::setView(PassRefPtr<FrameView> view) 223 void LocalFrame::setView(PassRefPtrWillBeRawPtr<FrameView> view)
206 { 224 {
225 ASSERT(!m_view || m_view != view);
207 detachView(); 226 detachView();
208 227
209 // Prepare for destruction now, so any unload event handlers get run and the LocalDOMWindow is 228 // Prepare for destruction now, so any unload event handlers get run and the LocalDOMWindow is
210 // notified. If we wait until the view is destroyed, then things won't be ho oked up enough for 229 // notified. If we wait until the view is destroyed, then things won't be ho oked up enough for
211 // these calls to work. 230 // these calls to work.
212 if (!view && document() && document()->isActive()) { 231 if (!view && document() && document()->isActive()) {
213 // FIXME: We don't call willRemove here. Why is that OK? 232 // FIXME: We don't call willRemove here. Why is that OK?
214 document()->prepareForDestruction(); 233 document()->prepareForDestruction();
215 } 234 }
216 235
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 ASSERT(this); 460 ASSERT(this);
442 ASSERT(page()); 461 ASSERT(page());
443 462
444 bool isLocalRoot = this->isLocalRoot(); 463 bool isLocalRoot = this->isLocalRoot();
445 464
446 if (isLocalRoot && view()) 465 if (isLocalRoot && view())
447 view()->setParentVisible(false); 466 view()->setParentVisible(false);
448 467
449 setView(nullptr); 468 setView(nullptr);
450 469
451 RefPtr<FrameView> frameView; 470 RefPtrWillBeRawPtr<FrameView> frameView = nullptr;
452 if (isLocalRoot) { 471 if (isLocalRoot) {
453 frameView = FrameView::create(this, viewportSize); 472 frameView = FrameView::create(this, viewportSize);
454 473
455 // The layout size is set by WebViewImpl to support @viewport 474 // The layout size is set by WebViewImpl to support @viewport
456 frameView->setLayoutSizeFixedToFrameSize(false); 475 frameView->setLayoutSizeFixedToFrameSize(false);
457 } else 476 } else
458 frameView = FrameView::create(this); 477 frameView = FrameView::create(this);
459 478
460 frameView->setScrollbarModes(horizontalScrollbarMode, verticalScrollbarMode, horizontalLock, verticalLock); 479 frameView->setScrollbarModes(horizontalScrollbarMode, verticalScrollbarMode, horizontalLock, verticalLock);
461 480
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 ratio *= pageZoomFactor(); 735 ratio *= pageZoomFactor();
717 return ratio; 736 return ratio;
718 } 737 }
719 738
720 void LocalFrame::disconnectOwnerElement() 739 void LocalFrame::disconnectOwnerElement()
721 { 740 {
722 if (owner()) { 741 if (owner()) {
723 if (Document* document = this->document()) 742 if (Document* document = this->document())
724 document->topDocument().clearAXObjectCache(); 743 document->topDocument().clearAXObjectCache();
725 #if ENABLE(OILPAN) 744 #if ENABLE(OILPAN)
745 // First give the plugin elements holding persisted,
746 // renderer-less plugins the opportunity to dispose of them.
747 for (HashSet<HTMLPlugInElement*>::const_iterator it = m_pluginElements.b egin(); it != m_pluginElements.end(); ++it)
748 (*it)->disconnectContentFrame();
749 m_pluginElements.clear();
750
726 // Clear the FrameView and FrameLoader right here rather than 751 // Clear the FrameView and FrameLoader right here rather than
727 // during finalization. Too late to access various heap objects 752 // during finalization. Too late to access various heap objects
728 // at that stage. 753 // at that stage.
729 setView(nullptr); 754 setView(nullptr);
730 loader().clear(); 755 loader().clear();
731 #endif 756 #endif
732 } 757 }
733 Frame::disconnectOwnerElement(); 758 Frame::disconnectOwnerElement();
734 } 759 }
735 760
736 LocalFrame* LocalFrame::localFrameRoot() 761 LocalFrame* LocalFrame::localFrameRoot()
737 { 762 {
738 LocalFrame* curFrame = this; 763 LocalFrame* curFrame = this;
739 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame()) 764 while (curFrame && curFrame->tree().parent() && curFrame->tree().parent()->i sLocalFrame())
740 curFrame = toLocalFrame(curFrame->tree().parent()); 765 curFrame = toLocalFrame(curFrame->tree().parent());
741 766
742 return curFrame; 767 return curFrame;
743 } 768 }
744 769
745 void LocalFrame::setPagePopupOwner(Element& owner) 770 void LocalFrame::setPagePopupOwner(Element& owner)
746 { 771 {
747 m_pagePopupOwner = &owner; 772 m_pagePopupOwner = &owner;
748 } 773 }
749 774
775 #if ENABLE(OILPAN)
776 void LocalFrame::registerPluginElement(HTMLPlugInElement* plugin)
777 {
778 m_pluginElements.add(plugin);
779 }
780
781 void LocalFrame::unregisterPluginElement(HTMLPlugInElement* plugin)
782 {
783 ASSERT(m_pluginElements.contains(plugin));
784 m_pluginElements.remove(plugin);
785 }
786 #endif
787
750 } // namespace blink 788 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698