Title: [142223] trunk/Source/WebCore
- Revision
- 142223
- Author
- [email protected]
- Date
- 2013-02-07 20:59:23 -0800 (Thu, 07 Feb 2013)
Log Message
NamedFlowCollection should be a ContextDestructionObserver
https://bugs.webkit.org/show_bug.cgi?id=99239
Patch by Hanyee Kim <[email protected]> on 2013-02-07
Reviewed by Adam Barth
This patch removes the raw pointer of Document in NamedFlowCollection.
It could be replaced with ContextDestructionObserver.
ContextDestructionObserver has the pointer and clears the pointer
automatically when the document is destroyed.
* dom/Document.cpp:
(WebCore::Document::~Document):
* dom/NamedFlowCollection.cpp:
(WebCore::NamedFlowCollection::NamedFlowCollection):
(WebCore::NamedFlowCollection::ensureFlowWithName):
(WebCore::NamedFlowCollection::discardNamedFlow):
(WebCore::NamedFlowCollection::document):
(WebCore):
* dom/NamedFlowCollection.h:
(NamedFlowCollection):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (142222 => 142223)
--- trunk/Source/WebCore/ChangeLog 2013-02-08 04:29:53 UTC (rev 142222)
+++ trunk/Source/WebCore/ChangeLog 2013-02-08 04:59:23 UTC (rev 142223)
@@ -1,3 +1,26 @@
+2013-02-07 Hanyee Kim <[email protected]>
+
+ NamedFlowCollection should be a ContextDestructionObserver
+ https://bugs.webkit.org/show_bug.cgi?id=99239
+
+ Reviewed by Adam Barth
+
+ This patch removes the raw pointer of Document in NamedFlowCollection.
+ It could be replaced with ContextDestructionObserver.
+ ContextDestructionObserver has the pointer and clears the pointer
+ automatically when the document is destroyed.
+
+ * dom/Document.cpp:
+ (WebCore::Document::~Document):
+ * dom/NamedFlowCollection.cpp:
+ (WebCore::NamedFlowCollection::NamedFlowCollection):
+ (WebCore::NamedFlowCollection::ensureFlowWithName):
+ (WebCore::NamedFlowCollection::discardNamedFlow):
+ (WebCore::NamedFlowCollection::document):
+ (WebCore):
+ * dom/NamedFlowCollection.h:
+ (NamedFlowCollection):
+
2013-02-07 Dean Jackson <[email protected]>
Followup review suggestions from Alexey Proskuryakov on
Modified: trunk/Source/WebCore/dom/Document.cpp (142222 => 142223)
--- trunk/Source/WebCore/dom/Document.cpp 2013-02-08 04:29:53 UTC (rev 142222)
+++ trunk/Source/WebCore/dom/Document.cpp 2013-02-08 04:59:23 UTC (rev 142223)
@@ -621,9 +621,6 @@
m_styleSheetCollection.clear();
- if (m_namedFlows)
- m_namedFlows->documentDestroyed();
-
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
Modified: trunk/Source/WebCore/dom/NamedFlowCollection.cpp (142222 => 142223)
--- trunk/Source/WebCore/dom/NamedFlowCollection.cpp 2013-02-08 04:29:53 UTC (rev 142222)
+++ trunk/Source/WebCore/dom/NamedFlowCollection.cpp 2013-02-08 04:59:23 UTC (rev 142223)
@@ -40,8 +40,8 @@
namespace WebCore {
-NamedFlowCollection::NamedFlowCollection(Document* doc)
- : m_document(doc)
+NamedFlowCollection::NamedFlowCollection(Document* document)
+ : ContextDestructionObserver(document)
{
}
@@ -81,7 +81,7 @@
RefPtr<WebKitNamedFlow> newFlow = WebKitNamedFlow::create(this, flowName);
m_namedFlows.add(newFlow.get());
- InspectorInstrumentation::didCreateNamedFlow(m_document, newFlow.get());
+ InspectorInstrumentation::didCreateNamedFlow(document(), newFlow.get());
return newFlow.release();
}
@@ -89,21 +89,24 @@
void NamedFlowCollection::discardNamedFlow(WebKitNamedFlow* namedFlow)
{
// The document is not valid anymore so the collection will be destroyed anyway.
- if (!m_document)
+ if (!document())
return;
ASSERT(namedFlow->flowState() == WebKitNamedFlow::FlowStateNull);
ASSERT(m_namedFlows.contains(namedFlow));
- InspectorInstrumentation::willRemoveNamedFlow(m_document, namedFlow);
+ InspectorInstrumentation::willRemoveNamedFlow(document(), namedFlow);
m_namedFlows.remove(namedFlow);
}
-void NamedFlowCollection::documentDestroyed()
+Document* NamedFlowCollection::document() const
{
- m_document = 0;
+ ScriptExecutionContext* context = ContextDestructionObserver::scriptExecutionContext();
+ ASSERT(!context || context->isDocument());
+ return static_cast<Document*>(context);
}
+
PassRefPtr<DOMNamedFlowCollection> NamedFlowCollection::createCSSOMSnapshot()
{
Vector<WebKitNamedFlow*> createdFlows;
Modified: trunk/Source/WebCore/dom/NamedFlowCollection.h (142222 => 142223)
--- trunk/Source/WebCore/dom/NamedFlowCollection.h 2013-02-08 04:29:53 UTC (rev 142222)
+++ trunk/Source/WebCore/dom/NamedFlowCollection.h 2013-02-08 04:59:23 UTC (rev 142223)
@@ -30,6 +30,7 @@
#ifndef NamedFlowCollection_h
#define NamedFlowCollection_h
+#include "ContextDestructionObserver.h"
#include "WebKitNamedFlow.h"
#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
@@ -42,7 +43,7 @@
class Document;
class DOMNamedFlowCollection;
-class NamedFlowCollection : public RefCounted<NamedFlowCollection> {
+class NamedFlowCollection : public RefCounted<NamedFlowCollection>, public ContextDestructionObserver {
public:
static PassRefPtr<NamedFlowCollection> create(Document* doc) { return adoptRef(new NamedFlowCollection(doc)); }
@@ -52,10 +53,8 @@
void discardNamedFlow(WebKitNamedFlow*);
- void documentDestroyed();
+ Document* document() const;
- Document* document() const { return m_document; }
-
virtual ~NamedFlowCollection() { }
PassRefPtr<DOMNamedFlowCollection> createCSSOMSnapshot();
@@ -68,7 +67,6 @@
explicit NamedFlowCollection(Document*);
- Document* m_document;
NamedFlowSet m_namedFlows;
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes