Bug 1345767 - Part 1: Create classes for each of the input types. r=smaug

MozReview-Commit-ID: 4O6YHHGsLBP
This commit is contained in:
Jessica Jong
2017-05-04 11:43:46 +08:00
parent 6060904c46
commit db76d4e652
14 changed files with 742 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
#include "nsIDOMNSEditableElement.h"
#include "nsIRadioVisitor.h"
#include "nsIPhonetic.h"
#include "InputType.h"
#include "HTMLFormSubmissionConstants.h"
#include "mozilla/Telemetry.h"
@@ -1182,6 +1183,9 @@ HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNo
mInputData.mState =
nsTextEditorState::Construct(this, &sCachedTextEditorState);
void* memory = mInputTypeMem;
mInputType = InputType::Create(this, mType, memory);
if (!gUploadLastDir)
HTMLInputElement::InitUploadLastDir();
@@ -1216,6 +1220,11 @@ HTMLInputElement::FreeData()
ReleaseTextEditorState(mInputData.mState);
mInputData.mState = nullptr;
}
if (mInputType) {
mInputType->DropReference();
mInputType = nullptr;
}
}
nsTextEditorState*
@@ -5242,6 +5251,8 @@ HTMLInputElement::HandleTypeChange(uint8_t aNewType, bool aNotify)
// We already have a copy of the value, lets free it and changes the type.
FreeData();
mType = aNewType;
void* memory = mInputTypeMem;
mInputType = InputType::Create(this, mType, memory);
if (IsSingleLineTextControl()) {