Commit 80cbb726 authored by tkent@chromium.org's avatar tkent@chromium.org

Oilpan: Prepare to move FormController and DocumentState to Oilpan heap, and...

Oilpan: Prepare to move FormController and DocumentState to Oilpan heap, and remove RefPtrs to HTMLFormControlElement and HTMLFormControlElementWithState.

Note: ValidationMessage has a raw pointer member to HTMLFormControlElement. This
CL doesn't make it traceable because a CL to remove ValidationMessage class is
in-progress. A ValidationMessage object is owned by the HTMLFormControlElement
object and the raw pointer is safe.

BUG=357163

Review URL: https://codereview.chromium.org/277753003

git-svn-id: svn://svn.chromium.org/blink/trunk@173710 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 1692c3c2
......@@ -639,12 +639,10 @@ void Document::dispose()
destroyTreeScopeData();
removeDetachedChildren();
#endif
// removeDetachedChildren() can access FormController.
m_formController.clear();
#if !ENABLE(OILPAN)
m_markers->clear();
m_cssCanvasElements.clear();
......@@ -5706,6 +5704,7 @@ void Document::trace(Visitor* visitor)
visitor->trace(m_topLayerElements);
visitor->trace(m_elemSheet);
visitor->trace(m_styleEngine);
visitor->trace(m_formController);
visitor->trace(m_fetcher);
visitor->trace(m_contextFeatures);
visitor->trace(m_styleSheetList);
......
......@@ -1245,7 +1245,7 @@ private:
OwnPtrWillBeMember<StyleEngine> m_styleEngine;
RefPtrWillBeMember<StyleSheetList> m_styleSheetList;
OwnPtr<FormController> m_formController;
OwnPtrWillBeMember<FormController> m_formController;
TextLinkColors m_textLinkColors;
const OwnPtr<VisitedLinkState> m_visitedLinkState;
......
......@@ -335,7 +335,7 @@ void HTMLFormElement::submit(Event* event, bool activateSubmitButton, bool proce
m_wasUserSubmitted = processingUserGesture;
RefPtr<HTMLFormControlElement> firstSuccessfulSubmitButton;
RefPtrWillBeRawPtr<HTMLFormControlElement> firstSuccessfulSubmitButton = nullptr;
bool needButtonActivation = activateSubmitButton; // do we need to activate a submit button?
const Vector<FormAssociatedElement*>& elements = associatedElements();
......
......@@ -374,15 +374,20 @@ void FormKeyGenerator::willDeleteForm(HTMLFormElement* form)
// ----------------------------------------------------------------------------
PassRefPtr<DocumentState> DocumentState::create()
PassRefPtrWillBeRawPtr<DocumentState> DocumentState::create()
{
return adoptRef(new DocumentState);
return adoptRefWillBeNoop(new DocumentState);
}
DocumentState::~DocumentState()
{
}
void DocumentState::trace(Visitor* visitor)
{
visitor->trace(m_formControls);
}
void DocumentState::addControl(HTMLFormControlElementWithState* control)
{
ASSERT(!m_formControls.contains(control));
......@@ -443,6 +448,11 @@ FormController::~FormController()
{
}
void FormController::trace(Visitor* visitor)
{
visitor->trace(m_documentState);
}
DocumentState* FormController::formElementsState() const
{
return m_documentState.get();
......
......@@ -23,6 +23,7 @@
#define FormController_h
#include "core/html/forms/RadioButtonGroupScope.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
#include "wtf/ListHashSet.h"
#include "wtf/Vector.h"
......@@ -73,28 +74,30 @@ inline void FormControlState::append(const String& value)
typedef HashMap<AtomicString, OwnPtr<SavedFormState> > SavedFormStateMap;
class DocumentState : public RefCounted<DocumentState> {
class DocumentState : public RefCountedWillBeGarbageCollectedFinalized<DocumentState> {
public:
static PassRefPtr<DocumentState> create();
static PassRefPtrWillBeRawPtr<DocumentState> create();
~DocumentState();
void trace(Visitor*);
void addControl(HTMLFormControlElementWithState*);
void removeControl(HTMLFormControlElementWithState*);
Vector<String> toStateVector();
private:
typedef ListHashSet<RefPtr<HTMLFormControlElementWithState>, 64> FormElementListHashSet;
typedef WillBeHeapListHashSet<RefPtrWillBeMember<HTMLFormControlElementWithState>, 64> FormElementListHashSet;
FormElementListHashSet m_formControls;
};
class FormController {
WTF_MAKE_FAST_ALLOCATED;
class FormController : public NoBaseWillBeGarbageCollectedFinalized<FormController> {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
static PassOwnPtr<FormController> create()
static PassOwnPtrWillBeRawPtr<FormController> create()
{
return adoptPtr(new FormController);
return adoptPtrWillBeNoop(new FormController);
}
~FormController();
void trace(Visitor*);
RadioButtonGroupScope& radioButtonGroupScope() { return m_radioButtonGroupScope; }
......@@ -116,7 +119,7 @@ private:
static void formStatesFromStateVector(const Vector<String>&, SavedFormStateMap&);
RadioButtonGroupScope m_radioButtonGroupScope;
RefPtr<DocumentState> m_documentState;
RefPtrWillBeMember<DocumentState> m_documentState;
SavedFormStateMap m_savedFormStateMap;
OwnPtr<FormKeyGenerator> m_formKeyGenerator;
};
......
......@@ -107,7 +107,7 @@ private:
IntPoint m_scrollPoint;
float m_pageScaleFactor;
Vector<String> m_documentStateVector;
RefPtr<DocumentState> m_documentState;
RefPtrWillBePersistent<DocumentState> m_documentState;
// If two HistoryItems have the same item sequence number, then they are
// clones of one another. Traversing history from one such HistoryItem to
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment