cachedInput.setIsTextArea(false);
exported = input->value().threadsafeCopy();
cachedInput.setMaxLength(input->maxLength());
- cachedInput.setInputElement(input);
+ cachedInput.setTypeFromElement(input);
// If this does not need to be threadsafe, we can use crossThreadString().
// See http://trac.webkit.org/changeset/49160.
cachedInput.setName(input->name().string().threadsafeCopy());
mName = WTF::String();
}
+void CachedInput::setTypeFromElement(WebCore::HTMLInputElement* element)
+{
+ ASSERT(element);
+
+ if (element->isPasswordField())
+ mType = PASSWORD;
+ else if (element->isSearchField())
+ mType = SEARCH;
+ else if (element->isEmailField())
+ mType = EMAIL;
+ else if (element->isNumberField())
+ mType = NUMBER;
+ else if (element->isTelephoneField())
+ mType = TELEPHONE;
+ else if (element->isURLField())
+ mType = URL;
+ else
+ mType = NORMAL_TEXT_FIELD;
+}
+
#if DUMP_NAV_CACHE
#define DEBUG_PRINT_BOOL(field) \
// Initiaized to 0 in its array, so nothing to do in the
// constructor
}
+
+ enum Type {
+ NONE = -1,
+ NORMAL_TEXT_FIELD = 0,
+ TEXT_AREA = 1,
+ PASSWORD = 2,
+ SEARCH = 3,
+ EMAIL = 4,
+ NUMBER = 5,
+ TELEPHONE = 6,
+ URL = 7
+ };
+
void* formPointer() const { return mForm; }
void init();
- WebCore::HTMLInputElement* inputElement() const { return mElement; }
+ void setTypeFromElement(WebCore::HTMLInputElement*);
+ Type getType() const { return mType; }
bool isRtlText() const { return mIsRtlText; }
bool isTextField() const { return mIsTextField; }
bool isTextArea() const { return mIsTextArea; }
int paddingRight() const { return mPaddingRight; }
int paddingTop() const { return mPaddingTop; }
void setFormPointer(void* form) { mForm = form; }
- void setInputElement(WebCore::HTMLInputElement* element) { mElement = element; }
void setIsRtlText(bool isRtlText) { mIsRtlText = isRtlText; }
void setIsTextField(bool isTextField) { mIsTextField = isTextField; }
void setIsTextArea(bool isTextArea) { mIsTextArea = isTextArea; }
void setPaddingTop(int top) { mPaddingTop = top; }
void setTextSize(int textSize) { mTextSize = textSize; }
int textSize() const { return mTextSize; }
+
private:
+
void* mForm;
WTF::String mName;
int mMaxLength;
int mPaddingRight;
int mPaddingTop;
int mTextSize;
- WebCore::HTMLInputElement* mElement;
+ Type mType;
bool mIsRtlText : 1;
bool mIsTextField : 1;
bool mIsTextArea : 1;
static bool nativeFocusCandidateIsPassword(JNIEnv *env, jobject obj)
{
const CachedInput* input = getInputCandidate(env, obj);
- HTMLInputElement* element = 0;
- if (input)
- element = input->inputElement();
- return element && element->isPasswordField();
+ return input && input->getType() == CachedInput::PASSWORD;
}
static bool nativeFocusCandidateIsRtlText(JNIEnv *env, jobject obj)
return input ? input->textSize() : 0;
}
-enum type {
- NONE = -1,
- NORMAL_TEXT_FIELD = 0,
- TEXT_AREA = 1,
- PASSWORD = 2,
- SEARCH = 3,
- EMAIL = 4,
- NUMBER = 5,
- TELEPHONE = 6,
- URL = 7
-};
-
static int nativeFocusCandidateType(JNIEnv *env, jobject obj)
{
const CachedInput* input = getInputCandidate(env, obj);
if (!input)
- return NONE;
+ return CachedInput::NONE;
if (input->isTextArea())
- return TEXT_AREA;
-
- HTMLInputElement* element = input->inputElement();
- // If the CachedInput is used to represent a TextArea,
- // we have no HTMLInputElement and should have already
- // returned above. We must have an HTMLInputElement now.
- ASSERT(element);
-
- if (element->isPasswordField())
- return PASSWORD;
- else if (element->isSearchField())
- return SEARCH;
- else if (element->isEmailField())
- return EMAIL;
- else if (element->isNumberField())
- return NUMBER;
- else if (element->isTelephoneField())
- return TELEPHONE;
- else if (element->isURLField())
- return URL;
- else
- return NORMAL_TEXT_FIELD;
+ return CachedInput::TEXT_AREA;
+
+ return input->getType();
}
static bool nativeFocusIsPlugin(JNIEnv *env, jobject obj)