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

Unified Diff: Source/core/dom/Document.cpp

Issue 262093006: Oilpan: Make the Node hierarchy RefCountedGarbageCollected instead of TreeShared. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address more comments. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 15f087205287c8e6d9258c13149744eb81a00a9c..9bdaf69ad741c9d53e0887da4f4424c4799b7abb 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -479,7 +479,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC
, m_animationClock(AnimationClock::create())
, m_timeline(DocumentTimeline::create(this))
, m_transitionTimeline(TransitionTimeline::create(this))
- , m_templateDocumentHost(0)
+ , m_templateDocumentHost(nullptr)
, m_didAssociateFormControlsTimer(this, &Document::didAssociateFormControlsTimerFired)
, m_hasViewportUnits(false)
, m_styleRecalcElementCounter(0)
@@ -534,14 +534,16 @@ Document::~Document()
// When they die in the same GC round, the list of visibility observers
// will not be empty on Document destruction.
ASSERT(m_visibilityObservers.isEmpty());
-#endif
if (m_templateDocument)
- m_templateDocument->m_templateDocumentHost = 0; // balanced in ensureTemplateDocument().
+ m_templateDocument->m_templateDocumentHost = nullptr; // balanced in ensureTemplateDocument().
+#endif
m_scriptRunner.clear();
+#if !ENABLE(OILPAN)
removeAllEventListenersRecursively();
haraken 2014/05/06 04:20:16 Removing this line is great, but we'll still need
Mads Ager (chromium) 2014/05/06 08:26:00 Yeah, we need to figure out how to deal with Inspe
+#endif
// Currently we believe that Document can never outlive the parser.
// Although the Document may be replaced synchronously, DocumentParsers
@@ -568,11 +570,11 @@ Document::~Document()
m_timeline->detachFromDocument();
m_transitionTimeline->detachFromDocument();
+#if !ENABLE(OILPAN)
// We need to destroy CSSFontSelector before destroying m_fetcher.
if (m_styleEngine)
m_styleEngine->detachFromDocument();
-#if !ENABLE(OILPAN)
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
#endif
@@ -600,7 +602,9 @@ Document::~Document()
void Document::dispose()
haraken 2014/05/06 04:20:16 Just to confirm: In oilpan, Document::dispose() is
Mads Ager (chromium) 2014/05/06 08:26:00 With Oilpan, dispose is called at the point where
{
+#if !ENABLE(OILPAN)
ASSERT_WITH_SECURITY_IMPLICATION(!m_deletionHasBegun);
+
// We must make sure not to be retaining any of our children through
// these extra pointers or we will create a reference cycle.
m_docType = nullptr;
@@ -625,13 +629,18 @@ void Document::dispose()
// removeDetachedChildren() doesn't always unregister IDs,
// so tear down scope information upfront to avoid having stale references in the map.
destroyTreeScopeData();
haraken 2014/05/06 04:20:16 As far as I read the comment in line 629 and 630,
Mads Ager (chromium) 2014/05/06 08:26:00 We are not calling removeDetachedChildren. The chi
+
removeDetachedChildren();
+#endif
+
// removeDetachedChildren() can access FormController.
m_formController.clear();
+#if !ENABLE(OILPAN)
m_markers->clear();
haraken 2014/05/06 04:20:16 Just to confirm: There is no problem in calling m_
Mads Ager (chromium) 2014/05/06 08:26:00 That's right. As long as the Document stays alive
m_cssCanvasElements.clear();
+#endif
// FIXME: consider using ActiveDOMObject.
if (m_scriptedAnimationController)
@@ -641,7 +650,10 @@ void Document::dispose()
if (svgExtensions())
accessSVGExtensions().pauseAnimations();
+#if !ENABLE(OILPAN)
m_lifecycle.advanceTo(DocumentLifecycle::Disposed);
haraken 2014/05/06 04:20:16 - I wonder why you need to remove this line. - If
Mads Ager (chromium) 2014/05/06 08:26:00 I removed this because we have collapsed Stopped a
+#endif
+
lifecycleNotifier().notifyDocumentWasDisposed();
}
@@ -1362,7 +1374,7 @@ void Document::setTitle(const String& title)
else if (!m_titleElement) {
if (HTMLElement* headElement = head()) {
m_titleElement = HTMLTitleElement::create(*this);
- headElement->appendChild(m_titleElement);
+ headElement->appendChild(m_titleElement.get());
}
}
@@ -2223,6 +2235,9 @@ void Document::detach(const AttachContext& context)
lifecycleNotifier().notifyDocumentWasDetached();
m_lifecycle.advanceTo(DocumentLifecycle::Stopped);
+#if ENABLE(OILPAN)
+ dispose();
haraken 2014/05/06 04:20:16 Just help me understand (very fundamental question
Mads Ager (chromium) 2014/05/06 08:26:00 When you detach the document it cannot be attached
+#endif
}
void Document::prepareForDestruction()
@@ -3525,7 +3540,7 @@ bool Document::setFocusedElement(PassRefPtr<Element> prpNewFocusedElement, Focus
return true;
bool focusChangeBlocked = false;
- RefPtr<Element> oldFocusedElement = m_focusedElement;
+ RefPtrWillBeRawPtr<Element> oldFocusedElement = m_focusedElement;
m_focusedElement = nullptr;
// Remove focus from the existing focus node (if any)
@@ -4878,7 +4893,7 @@ void Document::getCSSCanvasContext(const String& type, const String& name, int w
HTMLCanvasElement& Document::getCSSCanvasElement(const String& name)
{
- RefPtr<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, nullptr).storedValue->value;
+ RefPtrWillBeMember<HTMLCanvasElement>& element = m_cssCanvasElements.add(name, nullptr).storedValue->value;
haraken 2014/05/06 04:20:16 I forgot the previous discussion, but what was the
Mads Ager (chromium) 2014/05/06 08:26:00 This one is safe. The only way the add/new pattern
if (!element) {
element = HTMLCanvasElement::create(*this);
element->setAccelerationDisabled(true);
@@ -5663,10 +5678,28 @@ void Document::clearWeakMembers(Visitor* visitor)
void Document::trace(Visitor* visitor)
{
+ visitor->trace(m_docType);
+ visitor->trace(m_autofocusElement);
+ visitor->trace(m_focusedElement);
+ visitor->trace(m_hoverNode);
+ visitor->trace(m_activeHoverElement);
+ visitor->trace(m_documentElement);
+ visitor->trace(m_titleElement);
+ visitor->trace(m_currentScriptStack);
+ visitor->trace(m_transformSourceDocument);
+ visitor->trace(m_cssCanvasElements);
+ visitor->trace(m_topLayerElements);
+ visitor->trace(m_mediaQueryMatcher);
haraken 2014/05/06 04:20:16 You're tracing m_mediaQueryMatcher twice :)
Mads Ager (chromium) 2014/05/06 08:26:00 I REALLY don't want it to go away!!! ;-) Thanks H
+ visitor->trace(m_elemSheet);
+ visitor->trace(m_styleEngine);
visitor->trace(m_styleSheetList);
visitor->trace(m_mediaQueryMatcher);
+ visitor->trace(m_associatedFormControls);
+ visitor->trace(m_templateDocument);
+ visitor->trace(m_templateDocumentHost);
visitor->trace(m_visibilityObservers);
visitor->trace(m_contextFeatures);
+ visitor->trace(m_userActionElements);
visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
DocumentSupplementable::trace(visitor);
TreeScope::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698