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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 517043003: Move Frame to the Oilpan heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase past r182224 conflict Created 6 years, 3 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 1775
1776 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can 1776 // Entering here from inside layout or paint would be catastrophic since rec alcStyle can
1777 // tear down the render tree or (unfortunately) run script. Kill the whole r enderer if 1777 // tear down the render tree or (unfortunately) run script. Kill the whole r enderer if
1778 // someone managed to get into here from inside layout or paint. 1778 // someone managed to get into here from inside layout or paint.
1779 RELEASE_ASSERT(!view()->isInPerformLayout()); 1779 RELEASE_ASSERT(!view()->isInPerformLayout());
1780 RELEASE_ASSERT(!view()->isPainting()); 1780 RELEASE_ASSERT(!view()->isPainting());
1781 1781
1782 // Script can run below in WidgetUpdates, so protect the LocalFrame. 1782 // Script can run below in WidgetUpdates, so protect the LocalFrame.
1783 // FIXME: Can this still happen? How does script run inside 1783 // FIXME: Can this still happen? How does script run inside
1784 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ? 1784 // UpdateSuspendScope::performDeferredWidgetTreeOperations() ?
1785 RefPtr<LocalFrame> protect(m_frame); 1785 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1786 1786
1787 TRACE_EVENT_BEGIN0("blink", "Document::updateRenderTree"); 1787 TRACE_EVENT_BEGIN0("blink", "Document::updateRenderTree");
1788 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateRenderTree"); 1788 TRACE_EVENT_SCOPED_SAMPLING_STATE("blink", "UpdateRenderTree");
1789 1789
1790 // FIXME: Remove m_styleRecalcElementCounter, we should just use the accessC ount() on the resolver. 1790 // FIXME: Remove m_styleRecalcElementCounter, we should just use the accessC ount() on the resolver.
1791 m_styleRecalcElementCounter = 0; 1791 m_styleRecalcElementCounter = 0;
1792 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalcul ateStyles", "frame", frame()); 1792 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Recalcul ateStyles", "frame", frame());
1793 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack()); 1793 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline.stack"), " CallStack", "stack", InspectorCallStackEvent::currentCallStack());
1794 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing. 1794 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Timeli ne migrates to tracing.
1795 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this); 1795 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willRecalc ulateStyle(this);
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 2193
2194 m_styleEngine->didDetach(); 2194 m_styleEngine->didDetach();
2195 2195
2196 frameHost()->eventHandlerRegistry().documentDetached(*this); 2196 frameHost()->eventHandlerRegistry().documentDetached(*this);
2197 2197
2198 // This is required, as our LocalFrame might delete itself as soon as it det aches 2198 // This is required, as our LocalFrame might delete itself as soon as it det aches
2199 // us. However, this violates Node::detach() semantics, as it's never 2199 // us. However, this violates Node::detach() semantics, as it's never
2200 // possible to re-attach. Eventually Document::detach() should be renamed, 2200 // possible to re-attach. Eventually Document::detach() should be renamed,
2201 // or this setting of the frame to 0 could be made explicit in each of the 2201 // or this setting of the frame to 0 could be made explicit in each of the
2202 // callers of Document::detach(). 2202 // callers of Document::detach().
2203 m_frame = 0; 2203 m_frame = nullptr;
2204 2204
2205 if (m_mediaQueryMatcher) 2205 if (m_mediaQueryMatcher)
2206 m_mediaQueryMatcher->documentDetached(); 2206 m_mediaQueryMatcher->documentDetached();
2207 2207
2208 lifecycleNotifier().notifyDocumentWasDetached(); 2208 lifecycleNotifier().notifyDocumentWasDetached();
2209 m_lifecycle.advanceTo(DocumentLifecycle::Stopped); 2209 m_lifecycle.advanceTo(DocumentLifecycle::Stopped);
2210 #if ENABLE(OILPAN) 2210 #if ENABLE(OILPAN)
2211 // Done with the window, explicitly clear to hasten its 2211 // Done with the window, explicitly clear to hasten its
2212 // destruction. 2212 // destruction.
2213 clearDOMWindow(); 2213 clearDOMWindow();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 { 2250 {
2251 ASSERT(&axObjectCacheOwner() == this); 2251 ASSERT(&axObjectCacheOwner() == this);
2252 // Clear the cache member variable before calling delete because attempts 2252 // Clear the cache member variable before calling delete because attempts
2253 // are made to access it during destruction. 2253 // are made to access it during destruction.
2254 m_axObjectCache.clear(); 2254 m_axObjectCache.clear();
2255 } 2255 }
2256 2256
2257 AXObjectCache* Document::existingAXObjectCache() const 2257 AXObjectCache* Document::existingAXObjectCache() const
2258 { 2258 {
2259 // If the renderer is gone then we are in the process of destruction. 2259 // If the renderer is gone then we are in the process of destruction.
2260 // This method will be called before m_frame = 0. 2260 // This method will be called before m_frame = nullptr.
2261 if (!axObjectCacheOwner().renderView()) 2261 if (!axObjectCacheOwner().renderView())
2262 return 0; 2262 return 0;
2263 2263
2264 return axObjectCacheOwner().m_axObjectCache.get(); 2264 return axObjectCacheOwner().m_axObjectCache.get();
2265 } 2265 }
2266 2266
2267 AXObjectCache* Document::axObjectCache() const 2267 AXObjectCache* Document::axObjectCache() const
2268 { 2268 {
2269 Settings* settings = this->settings(); 2269 Settings* settings = this->settings();
2270 if (!settings || !settings->accessibilityEnabled()) 2270 if (!settings || !settings->accessibilityEnabled())
(...skipping 2378 matching lines...) Expand 10 before | Expand all | Expand 10 after
4649 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e(); 4649 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e();
4650 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4650 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
4651 if (!m_documentTiming.domContentLoadedEventEnd) 4651 if (!m_documentTiming.domContentLoadedEventEnd)
4652 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime( ); 4652 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime( );
4653 4653
4654 // The loader's finishedParsing() method may invoke script that causes this object to 4654 // The loader's finishedParsing() method may invoke script that causes this object to
4655 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change). 4655 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
4656 // Keep it alive until we are done. 4656 // Keep it alive until we are done.
4657 RefPtrWillBeRawPtr<Document> protect(this); 4657 RefPtrWillBeRawPtr<Document> protect(this);
4658 4658
4659 if (RefPtr<LocalFrame> f = frame()) { 4659 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) {
4660 // Don't update the render tree if we haven't requested the main resourc e yet to avoid 4660 // Don't update the render tree if we haven't requested the main resourc e yet to avoid
4661 // adding extra latency. Note that the first render tree update can be e xpensive since it 4661 // adding extra latency. Note that the first render tree update can be e xpensive since it
4662 // triggers the parsing of the default stylesheets which are compiled-in . 4662 // triggers the parsing of the default stylesheets which are compiled-in .
4663 const bool mainResourceWasAlreadyRequested = 4663 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad();
4664 m_frame->loader().stateMachine()->committedFirstRealDocumentLoad();
4665 4664
4666 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all 4665 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all
4667 // resource loads are complete. HTMLObjectElements can start loading the ir resources from 4666 // resource loads are complete. HTMLObjectElements can start loading the ir resources from
4668 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object> 4667 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object>
4669 // tag and then reach the end of the document without updating styles, w e might not have yet 4668 // tag and then reach the end of the document without updating styles, w e might not have yet
4670 // started the resource load and might fire the window load event too ea rly. To avoid this 4669 // started the resource load and might fire the window load event too ea rly. To avoid this
4671 // we force the styles to be up to date before calling FrameLoader::fini shedParsing(). 4670 // we force the styles to be up to date before calling FrameLoader::fini shedParsing().
4672 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com ment 35. 4671 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com ment 35.
4673 if (mainResourceWasAlreadyRequested) 4672 if (mainResourceWasAlreadyRequested)
4674 updateRenderTreeIfNeeded(); 4673 updateRenderTreeIfNeeded();
4675 4674
4676 f->loader().finishedParsing(); 4675 frame->loader().finishedParsing();
4677 4676
4678 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma rkDOMContent", "data", InspectorMarkLoadEvent::data(f.get())); 4677 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma rkDOMContent", "data", InspectorMarkLoadEvent::data(frame.get()));
4679 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 4678 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
4680 InspectorInstrumentation::domContentLoadedEventFired(f.get()); 4679 InspectorInstrumentation::domContentLoadedEventFired(frame.get());
4681 } 4680 }
4682 4681
4683 // Schedule dropping of the ElementDataCache. We keep it alive for a while a fter parsing finishes 4682 // Schedule dropping of the ElementDataCache. We keep it alive for a while a fter parsing finishes
4684 // so that dynamically inserted content can also benefit from sharing optimi zations. 4683 // so that dynamically inserted content can also benefit from sharing optimi zations.
4685 // Note that we don't refresh the timer on cache access since that could lea d to huge caches being kept 4684 // Note that we don't refresh the timer on cache access since that could lea d to huge caches being kept
4686 // alive indefinitely by something innocuous like JS setting .innerHTML repe atedly on a timer. 4685 // alive indefinitely by something innocuous like JS setting .innerHTML repe atedly on a timer.
4687 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE); 4686 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE);
4688 4687
4689 // Parser should have picked up all preloads by now 4688 // Parser should have picked up all preloads by now
4690 m_fetcher->clearPreloads(); 4689 m_fetcher->clearPreloads();
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5808 for (int i = 0; i < numNodeListInvalidationTypes; ++i) 5807 for (int i = 0; i < numNodeListInvalidationTypes; ++i)
5809 visitor->trace(m_nodeLists[i]); 5808 visitor->trace(m_nodeLists[i]);
5810 visitor->trace(m_cssCanvasElements); 5809 visitor->trace(m_cssCanvasElements);
5811 visitor->trace(m_topLayerElements); 5810 visitor->trace(m_topLayerElements);
5812 visitor->trace(m_elemSheet); 5811 visitor->trace(m_elemSheet);
5813 visitor->trace(m_nodeIterators); 5812 visitor->trace(m_nodeIterators);
5814 visitor->trace(m_ranges); 5813 visitor->trace(m_ranges);
5815 visitor->trace(m_styleEngine); 5814 visitor->trace(m_styleEngine);
5816 visitor->trace(m_formController); 5815 visitor->trace(m_formController);
5817 visitor->trace(m_visitedLinkState); 5816 visitor->trace(m_visitedLinkState);
5817 visitor->trace(m_frame);
5818 visitor->trace(m_domWindow); 5818 visitor->trace(m_domWindow);
5819 visitor->trace(m_fetcher); 5819 visitor->trace(m_fetcher);
5820 visitor->trace(m_parser); 5820 visitor->trace(m_parser);
5821 visitor->trace(m_contextFeatures); 5821 visitor->trace(m_contextFeatures);
5822 visitor->trace(m_styleSheetList); 5822 visitor->trace(m_styleSheetList);
5823 visitor->trace(m_mediaQueryMatcher); 5823 visitor->trace(m_mediaQueryMatcher);
5824 visitor->trace(m_scriptedAnimationController); 5824 visitor->trace(m_scriptedAnimationController);
5825 visitor->trace(m_textAutosizer); 5825 visitor->trace(m_textAutosizer);
5826 visitor->trace(m_registrationContext); 5826 visitor->trace(m_registrationContext);
5827 visitor->trace(m_customElementMicrotaskRunQueue); 5827 visitor->trace(m_customElementMicrotaskRunQueue);
(...skipping 24 matching lines...) Expand all
5852 using namespace blink; 5852 using namespace blink;
5853 void showLiveDocumentInstances() 5853 void showLiveDocumentInstances()
5854 { 5854 {
5855 WeakDocumentSet& set = liveDocumentSet(); 5855 WeakDocumentSet& set = liveDocumentSet();
5856 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5856 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5857 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5857 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5858 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5858 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5859 } 5859 }
5860 } 5860 }
5861 #endif 5861 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698