https://bugs.webkit.org/show_bug.cgi?id=99239
Patch by Hanyee Kim <choco@company100.net> 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):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@142223
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-02-07 Hanyee Kim <choco@company100.net>
+
+ 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 <dino@apple.com>
Followup review suggestions from Alexey Proskuryakov on
m_styleSheetCollection.clear();
- if (m_namedFlows)
- m_namedFlows->documentDestroyed();
-
if (m_elemSheet)
m_elemSheet->clearOwnerNode();
namespace WebCore {
-NamedFlowCollection::NamedFlowCollection(Document* doc)
- : m_document(doc)
+NamedFlowCollection::NamedFlowCollection(Document* document)
+ : ContextDestructionObserver(document)
{
}
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();
}
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;
#ifndef NamedFlowCollection_h
#define NamedFlowCollection_h
+#include "ContextDestructionObserver.h"
#include "WebKitNamedFlow.h"
#include <wtf/Forward.h>
#include <wtf/ListHashSet.h>
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)); }
void discardNamedFlow(WebKitNamedFlow*);
- void documentDestroyed();
-
- Document* document() const { return m_document; }
+ Document* document() const;
virtual ~NamedFlowCollection() { }
explicit NamedFlowCollection(Document*);
- Document* m_document;
NamedFlowSet m_namedFlows;
};