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

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: Back out non-Oilpan experiment + tidy up by adding frame() ref accessors 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 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after
4644 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e(); 4644 m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTim e();
4645 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded)); 4645 dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
4646 if (!m_documentTiming.domContentLoadedEventEnd) 4646 if (!m_documentTiming.domContentLoadedEventEnd)
4647 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime( ); 4647 m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime( );
4648 4648
4649 // The loader's finishedParsing() method may invoke script that causes this object to 4649 // The loader's finishedParsing() method may invoke script that causes this object to
4650 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change). 4650 // be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
4651 // Keep it alive until we are done. 4651 // Keep it alive until we are done.
4652 RefPtrWillBeRawPtr<Document> protect(this); 4652 RefPtrWillBeRawPtr<Document> protect(this);
4653 4653
4654 if (RefPtr<LocalFrame> f = frame()) { 4654 if (RefPtrWillBeRawPtr<LocalFrame> frame = this->frame()) {
4655 // Don't update the render tree if we haven't requested the main resourc e yet to avoid 4655 // Don't update the render tree if we haven't requested the main resourc e yet to avoid
4656 // adding extra latency. Note that the first render tree update can be e xpensive since it 4656 // adding extra latency. Note that the first render tree update can be e xpensive since it
4657 // triggers the parsing of the default stylesheets which are compiled-in . 4657 // triggers the parsing of the default stylesheets which are compiled-in .
4658 const bool mainResourceWasAlreadyRequested = 4658 const bool mainResourceWasAlreadyRequested = frame->loader().stateMachin e()->committedFirstRealDocumentLoad();
4659 m_frame->loader().stateMachine()->committedFirstRealDocumentLoad();
4660 4659
4661 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all 4660 // FrameLoader::finishedParsing() might end up calling Document::implici tClose() if all
4662 // resource loads are complete. HTMLObjectElements can start loading the ir resources from 4661 // resource loads are complete. HTMLObjectElements can start loading the ir resources from
4663 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object> 4662 // post attach callbacks triggered by recalcStyle(). This means if we p arse out an <object>
4664 // tag and then reach the end of the document without updating styles, w e might not have yet 4663 // tag and then reach the end of the document without updating styles, w e might not have yet
4665 // started the resource load and might fire the window load event too ea rly. To avoid this 4664 // started the resource load and might fire the window load event too ea rly. To avoid this
4666 // we force the styles to be up to date before calling FrameLoader::fini shedParsing(). 4665 // we force the styles to be up to date before calling FrameLoader::fini shedParsing().
4667 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com ment 35. 4666 // See https://bugs.webkit.org/show_bug.cgi?id=36864 starting around com ment 35.
4668 if (mainResourceWasAlreadyRequested) 4667 if (mainResourceWasAlreadyRequested)
4669 updateRenderTreeIfNeeded(); 4668 updateRenderTreeIfNeeded();
4670 4669
4671 f->loader().finishedParsing(); 4670 frame->loader().finishedParsing();
4672 4671
4673 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma rkDOMContent", "data", InspectorMarkLoadEvent::data(f.get())); 4672 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Ma rkDOMContent", "data", InspectorMarkLoadEvent::data(frame.get()));
4674 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing. 4673 // FIXME(361045): remove InspectorInstrumentation calls once DevTools Ti meline migrates to tracing.
4675 InspectorInstrumentation::domContentLoadedEventFired(f.get()); 4674 InspectorInstrumentation::domContentLoadedEventFired(frame.get());
4676 } 4675 }
4677 4676
4678 // Schedule dropping of the ElementDataCache. We keep it alive for a while a fter parsing finishes 4677 // Schedule dropping of the ElementDataCache. We keep it alive for a while a fter parsing finishes
4679 // so that dynamically inserted content can also benefit from sharing optimi zations. 4678 // so that dynamically inserted content can also benefit from sharing optimi zations.
4680 // Note that we don't refresh the timer on cache access since that could lea d to huge caches being kept 4679 // Note that we don't refresh the timer on cache access since that could lea d to huge caches being kept
4681 // alive indefinitely by something innocuous like JS setting .innerHTML repe atedly on a timer. 4680 // alive indefinitely by something innocuous like JS setting .innerHTML repe atedly on a timer.
4682 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE); 4681 m_elementDataCacheClearTimer.startOneShot(10, FROM_HERE);
4683 4682
4684 // Parser should have picked up all preloads by now 4683 // Parser should have picked up all preloads by now
4685 m_fetcher->clearPreloads(); 4684 m_fetcher->clearPreloads();
(...skipping 1117 matching lines...) Expand 10 before | Expand all | Expand 10 after
5803 for (int i = 0; i < numNodeListInvalidationTypes; ++i) 5802 for (int i = 0; i < numNodeListInvalidationTypes; ++i)
5804 visitor->trace(m_nodeLists[i]); 5803 visitor->trace(m_nodeLists[i]);
5805 visitor->trace(m_cssCanvasElements); 5804 visitor->trace(m_cssCanvasElements);
5806 visitor->trace(m_topLayerElements); 5805 visitor->trace(m_topLayerElements);
5807 visitor->trace(m_elemSheet); 5806 visitor->trace(m_elemSheet);
5808 visitor->trace(m_nodeIterators); 5807 visitor->trace(m_nodeIterators);
5809 visitor->trace(m_ranges); 5808 visitor->trace(m_ranges);
5810 visitor->trace(m_styleEngine); 5809 visitor->trace(m_styleEngine);
5811 visitor->trace(m_formController); 5810 visitor->trace(m_formController);
5812 visitor->trace(m_visitedLinkState); 5811 visitor->trace(m_visitedLinkState);
5812 visitor->trace(m_frame);
5813 visitor->trace(m_domWindow); 5813 visitor->trace(m_domWindow);
5814 visitor->trace(m_fetcher); 5814 visitor->trace(m_fetcher);
5815 visitor->trace(m_parser); 5815 visitor->trace(m_parser);
5816 visitor->trace(m_contextFeatures); 5816 visitor->trace(m_contextFeatures);
5817 visitor->trace(m_styleSheetList); 5817 visitor->trace(m_styleSheetList);
5818 visitor->trace(m_mediaQueryMatcher); 5818 visitor->trace(m_mediaQueryMatcher);
5819 visitor->trace(m_scriptedAnimationController); 5819 visitor->trace(m_scriptedAnimationController);
5820 visitor->trace(m_textAutosizer); 5820 visitor->trace(m_textAutosizer);
5821 visitor->trace(m_registrationContext); 5821 visitor->trace(m_registrationContext);
5822 visitor->trace(m_customElementMicrotaskRunQueue); 5822 visitor->trace(m_customElementMicrotaskRunQueue);
(...skipping 24 matching lines...) Expand all
5847 using namespace blink; 5847 using namespace blink;
5848 void showLiveDocumentInstances() 5848 void showLiveDocumentInstances()
5849 { 5849 {
5850 WeakDocumentSet& set = liveDocumentSet(); 5850 WeakDocumentSet& set = liveDocumentSet();
5851 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5851 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5852 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) { 5852 for (WeakDocumentSet::const_iterator it = set.begin(); it != set.end(); ++it ) {
5853 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data()); 5853 fprintf(stderr, "- Document %p URL: %s\n", *it, (*it)->url().string().ut f8().data());
5854 } 5854 }
5855 } 5855 }
5856 #endif 5856 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698