Commit a6cb255b authored by darin@apple.com's avatar darin@apple.com

2010-09-16 Darin Adler <darin@apple.com>

        Reviewed by Andreas Kling.

        Reduce use of HTMLInputElement::inputType so we can remove it later
        https://bugs.webkit.org/show_bug.cgi?id=45903

        * src/DOMUtilitiesPrivate.cpp:
        (WebKit::elementHasLegalLinkAttribute): Use isImageButton.
        * src/WebPasswordFormUtils.cpp:
        (WebKit::findPasswordFormFields): Use isPasswordField.
        * src/WebSearchableFormData.cpp:
        (WebCore::IsInDefaultState): Use isCheckbox and isRadioButton.
        (WebCore::HasSuitableTextElement): Use isFileUpload and isPasswordField.
2010-09-16  Darin Adler  <darin@apple.com>

        Reviewed by Andreas Kling.

        Reduce use of HTMLInputElement::inputType so we can remove it later
        https://bugs.webkit.org/show_bug.cgi?id=45903

        * WebCoreSupport/DumpRenderTreeSupportQt.cpp:
        (DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId):
        Use isPasswordField.
2010-09-16  Darin Adler  <darin@apple.com>

        Reviewed by Andreas Kling.

        Reduce use of HTMLInputElement::inputType so we can remove it later
        https://bugs.webkit.org/show_bug.cgi?id=45903

        * WebFrame.cpp:
        (WebFrame::elementDoesAutoComplete): Use isPasswordField.
        (WebFrame::elementIsPassword): Use isPasswordField.
2010-09-16  Darin Adler  <darin@apple.com>

        Reviewed by Andreas Kling.

        Reduce use of HTMLInputElement::inputType so we can remove it later
        https://bugs.webkit.org/show_bug.cgi?id=45903

        * WebView/WebHTMLRepresentation.mm:
        (-[WebHTMLRepresentation elementDoesAutoComplete:]): Use isPasswordField.
        (-[WebHTMLRepresentation elementIsPassword:]): Use isPasswordField.
2010-09-16  Darin Adler  <darin@apple.com>

        Reviewed by Andreas Kling.

        Reduce use of HTMLInputElement::inputType so we can remove it later
        https://bugs.webkit.org/show_bug.cgi?id=45903

        * accessibility/AccessibilityRenderObject.cpp:
        (WebCore::AccessibilityRenderObject::isFileUploadButton): Use isFileUpload.
        (WebCore::AccessibilityRenderObject::isInputImage): Use isImageButton.
        (WebCore::AccessibilityRenderObject::determineAccessibilityRole): Use
        isCheckbox and isRadioButton.

        * css/CSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::adjustRenderStyle): Use isImageButton.

        * editing/Editor.cpp:
        (WebCore::Editor::setBaseWritingDirection): Use isTextField.

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply): Use isPasswordField.

        * editing/SelectionController.cpp:
        (WebCore::SelectionController::isInPasswordField): Use isPasswordField.

        * html/HTMLInputElement.h: Added isFileUpload, isImageButton, and isSubmitButton.

        * page/Chrome.cpp:
        (WebCore::Chrome::setToolTip): Use isSubmitButton and isFileUpload.

        * page/DragController.cpp:
        (WebCore::asFileInput): Use isFileUpload.

        * page/EventHandler.cpp:
        (WebCore::isSubmitImage): Use isImageButton.

        * rendering/RenderFileUploadControl.cpp:
        (WebCore::RenderFileUploadControl::updateFromElement): Use isFileUpload.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@67653 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 462ba4b7
2010-09-16 Darin Adler <darin@apple.com>
Reviewed by Andreas Kling.
Reduce use of HTMLInputElement::inputType so we can remove it later
https://bugs.webkit.org/show_bug.cgi?id=45903
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::isFileUploadButton): Use isFileUpload.
(WebCore::AccessibilityRenderObject::isInputImage): Use isImageButton.
(WebCore::AccessibilityRenderObject::determineAccessibilityRole): Use
isCheckbox and isRadioButton.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::adjustRenderStyle): Use isImageButton.
* editing/Editor.cpp:
(WebCore::Editor::setBaseWritingDirection): Use isTextField.
* editing/ReplaceSelectionCommand.cpp:
(WebCore::ReplaceSelectionCommand::doApply): Use isPasswordField.
* editing/SelectionController.cpp:
(WebCore::SelectionController::isInPasswordField): Use isPasswordField.
* html/HTMLInputElement.h: Added isFileUpload, isImageButton, and isSubmitButton.
* page/Chrome.cpp:
(WebCore::Chrome::setToolTip): Use isSubmitButton and isFileUpload.
* page/DragController.cpp:
(WebCore::asFileInput): Use isFileUpload.
* page/EventHandler.cpp:
(WebCore::isSubmitImage): Use isImageButton.
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::updateFromElement): Use isFileUpload.
2010-09-16 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Pavel Feldman.
......@@ -503,7 +503,7 @@ bool AccessibilityRenderObject::isFileUploadButton() const
{
if (m_renderer && m_renderer->node() && m_renderer->node()->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(m_renderer->node());
return input->inputType() == HTMLInputElement::FILE;
return input->isFileUpload();
}
return false;
......@@ -514,7 +514,7 @@ bool AccessibilityRenderObject::isInputImage() const
Node* elementNode = node();
if (roleValue() == ButtonRole && elementNode && elementNode->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(elementNode);
return input->inputType() == HTMLInputElement::IMAGE;
return input->isImageButton();
}
return false;
......@@ -3036,9 +3036,9 @@ AccessibilityRole AccessibilityRenderObject::determineAccessibilityRole()
if (node && node->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
if (input->inputType() == HTMLInputElement::CHECKBOX)
if (input->isCheckbox())
return CheckBoxRole;
if (input->inputType() == HTMLInputElement::RADIO)
if (input->isRadioButton())
return RadioButtonRole;
if (input->isTextButton())
return ButtonRole;
......
......@@ -1796,7 +1796,7 @@ void CSSStyleSelector::adjustRenderStyle(RenderStyle* style, Element *e)
if (e && e->isFormControlElement() && style->fontSize() >= 11) {
// Don't apply intrinsic margins to image buttons. The designer knows how big the images are,
// so we have to treat all image buttons as though they were explicitly sized.
if (!e->hasTagName(inputTag) || static_cast<HTMLInputElement*>(e)->inputType() != HTMLInputElement::IMAGE)
if (!e->hasTagName(inputTag) || !static_cast<HTMLInputElement*>(e)->isImageButton())
addIntrinsicMargins(style);
}
......
......@@ -1451,9 +1451,7 @@ void Editor::toggleUnderline()
void Editor::setBaseWritingDirection(WritingDirection direction)
{
Node* focusedNode = frame()->document()->focusedNode();
if (focusedNode && (focusedNode->hasTagName(textareaTag)
|| (focusedNode->hasTagName(inputTag) && (static_cast<HTMLInputElement*>(focusedNode)->inputType() == HTMLInputElement::TEXT
|| static_cast<HTMLInputElement*>(focusedNode)->inputType() == HTMLInputElement::SEARCH)))) {
if (focusedNode && (focusedNode->hasTagName(textareaTag) || (focusedNode->hasTagName(inputTag) && static_cast<HTMLInputElement*>(focusedNode)->isTextField()))) {
if (direction == NaturalWritingDirection)
return;
static_cast<HTMLElement*>(focusedNode)->setAttribute(dirAttr, direction == LeftToRightWritingDirection ? "ltr" : "rtl");
......
......@@ -1062,7 +1062,7 @@ void ReplaceSelectionCommand::doApply()
if (m_smartReplace && currentRoot) {
// Disable smart replace for password fields.
Node* start = currentRoot->shadowAncestorNode();
if (start->hasTagName(inputTag) && static_cast<HTMLInputElement*>(start)->inputType() == HTMLInputElement::PASSWORD)
if (start->hasTagName(inputTag) && static_cast<HTMLInputElement*>(start)->isPasswordField())
m_smartReplace = false;
}
if (m_smartReplace) {
......
......@@ -1332,7 +1332,7 @@ bool SelectionController::isInPasswordField() const
if (!startNode->hasTagName(inputTag))
return false;
return static_cast<HTMLInputElement*>(startNode)->inputType() == HTMLInputElement::PASSWORD;
return static_cast<HTMLInputElement*>(startNode)->isPasswordField();
}
bool SelectionController::caretRendersInsideNode(Node* node) const
......
......@@ -102,16 +102,22 @@ public:
void stepUpFromRenderer(int);
bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; }
virtual bool isRadioButton() const { return m_type == RADIO; }
virtual bool isTextField() const;
virtual bool isSearchField() const { return m_type == SEARCH; }
virtual bool isInputTypeHidden() const { return m_type == HIDDEN; }
virtual bool isPasswordField() const { return m_type == PASSWORD; }
virtual bool isCheckbox() const { return m_type == CHECKBOX; }
bool isTelephoneField() const { return m_type == TELEPHONE; }
bool isNumberField() const { return m_type == NUMBER; }
bool isEmailField() const { return m_type == EMAIL; }
bool isUrlField() const { return m_type == URL; }
bool isFileUpload() const { return m_type == FILE; }
bool isImageButton() const { return m_type == IMAGE; }
bool isNumberField() const { return m_type == NUMBER; }
bool isSubmitButton() const { return m_type == SUBMIT; }
bool isTelephoneField() const { return m_type == TELEPHONE; }
bool isURLField() const { return m_type == URL; }
#if ENABLE(INPUT_SPEECH)
virtual bool isSpeechEnabled() const;
#endif
......
......@@ -350,7 +350,7 @@ void Chrome::setToolTip(const HitTestResult& result)
// Get tooltip representing form action, if relevant
if (node->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
if (input->inputType() == HTMLInputElement::SUBMIT)
if (input->isSubmitButton())
if (HTMLFormElement* form = input->form()) {
toolTip = form->action();
if (form->renderer())
......@@ -379,7 +379,7 @@ void Chrome::setToolTip(const HitTestResult& result)
if (Node* node = result.innerNonSharedNode()) {
if (node->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
if (input->inputType() == HTMLInputElement::FILE) {
if (input->isFileUpload()) {
FileList* files = input->files();
unsigned listSize = files->length();
if (files && listSize > 1) {
......
......@@ -255,17 +255,17 @@ static HTMLInputElement* asFileInput(Node* node)
// The button for a FILE input is a sub element with no set input type
// In order to get around this problem we assume any non-FILE input element
// is this internal button, and try querying the shadow parent node.
if (node->hasTagName(HTMLNames::inputTag) && node->isShadowNode() && static_cast<HTMLInputElement*>(node)->inputType() != HTMLInputElement::FILE)
node = node->shadowParentNode();
if (node->hasTagName(HTMLNames::inputTag) && node->isShadowNode() && !static_cast<HTMLInputElement*>(node)->isFileUpload())
node = node->shadowParentNode();
if (!node || !node->hasTagName(HTMLNames::inputTag))
return 0;
HTMLInputElement* inputElem = static_cast<HTMLInputElement*>(node);
if (inputElem->inputType() == HTMLInputElement::FILE)
return inputElem;
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(node);
if (!inputElement->isFileUpload())
return 0;
return 0;
return inputElement;
}
static Element* elementUnderMouse(Document* documentUnderMouse, const IntPoint& p)
......
......@@ -1045,8 +1045,7 @@ Frame* EventHandler::subframeForTargetNode(Node* node)
static bool isSubmitImage(Node* node)
{
return node && node->hasTagName(inputTag)
&& static_cast<HTMLInputElement*>(node)->inputType() == HTMLInputElement::IMAGE;
return node && node->hasTagName(inputTag) && static_cast<HTMLInputElement*>(node)->isImageButton();
}
// Returns true if the node's editable block is not current focused for editing
......
......@@ -142,7 +142,7 @@ Chrome* RenderFileUploadControl::chrome() const
void RenderFileUploadControl::updateFromElement()
{
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(node());
ASSERT(inputElement->inputType() == HTMLInputElement::FILE);
ASSERT(inputElement->isFileUpload());
if (!m_button) {
m_button = ShadowInputElement::create(inputElement);
......
2010-09-16 Darin Adler <darin@apple.com>
Reviewed by Andreas Kling.
Reduce use of HTMLInputElement::inputType so we can remove it later
https://bugs.webkit.org/show_bug.cgi?id=45903
* src/DOMUtilitiesPrivate.cpp:
(WebKit::elementHasLegalLinkAttribute): Use isImageButton.
* src/WebPasswordFormUtils.cpp:
(WebKit::findPasswordFormFields): Use isPasswordField.
* src/WebSearchableFormData.cpp:
(WebCore::IsInDefaultState): Use isCheckbox and isRadioButton.
(WebCore::HasSuitableTextElement): Use isFileUpload and isPasswordField.
2010-09-16 Kenneth Russell <kbr@google.com>
Reviewed by James Robinson.
......
......@@ -97,7 +97,7 @@ bool elementHasLegalLinkAttribute(const Element* element,
if (element->hasTagName(HTMLNames::inputTag)) {
const HTMLInputElement* input =
static_cast<const HTMLInputElement*>(element);
if (input->inputType() == HTMLInputElement::IMAGE)
if (input->isImageButton())
return true;
}
} else if (attrName == HTMLNames::hrefAttr) {
......
......@@ -79,8 +79,8 @@ void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields)
continue;
if ((fields->passwords.size() < maxPasswords)
&& (inputElement->inputType() == HTMLInputElement::PASSWORD)
&& (inputElement->autoComplete())) {
&& inputElement->isPasswordField()
&& inputElement->autoComplete()) {
if (fields->passwords.isEmpty())
firstPasswordIndex = i;
fields->passwords.append(inputElement);
......@@ -98,6 +98,7 @@ void findPasswordFormFields(HTMLFormElement* form, PasswordFormFields* fields)
if (!inputElement->isEnabledFormControl())
continue;
// FIXME: This needs to use a function other than inputType.
if ((inputElement->inputType() == HTMLInputElement::TEXT)
&& (inputElement->autoComplete())) {
fields->userName = inputElement;
......
......@@ -131,7 +131,7 @@ bool IsInDefaultState(const HTMLFormControlElement* formElement)
{
if (formElement->hasTagName(HTMLNames::inputTag)) {
const HTMLInputElement* inputElement = static_cast<const HTMLInputElement*>(formElement);
if (inputElement->inputType() == HTMLInputElement::CHECKBOX || inputElement->inputType() == HTMLInputElement::RADIO)
if (inputElement->isCheckbox() || inputElement->isRadioButton())
return inputElement->checked() == inputElement->defaultChecked();
} else if (formElement->hasTagName(HTMLNames::selectTag))
return IsSelectInDefaultState(static_cast<const HTMLSelectElement*>(formElement));
......@@ -166,19 +166,24 @@ bool HasSuitableTextElement(const HTMLFormElement* form, Vector<char>* encodedSt
bool isTextElement = false;
if (formElement->hasTagName(HTMLNames::inputTag)) {
if (static_cast<const HTMLInputElement*>(formElement)->isFileUpload()) {
// Too big, don't try to index this.
return 0;
}
if (static_cast<const HTMLInputElement*>(formElement)->isPasswordField()) {
// Don't store passwords! This is most likely an https anyway.
return 0;
}
// FIXME: This needs to use a function on HTMLInputElement other than inputType.
// Also, it's not clear why TEXT should be handled differently than, say, SEARCH.
switch (static_cast<const HTMLInputElement*>(formElement)->inputType()) {
case HTMLInputElement::TEXT:
case HTMLInputElement::ISINDEX:
isTextElement = true;
break;
case HTMLInputElement::PASSWORD:
// Don't store passwords! This is most likely an https anyway.
// Fall through.
case HTMLInputElement::FILE:
// Too big, don't try to index this.
return 0;
default:
// All other input types are indexable.
break;
}
}
......
2010-09-16 Darin Adler <darin@apple.com>
Reviewed by Andreas Kling.
Reduce use of HTMLInputElement::inputType so we can remove it later
https://bugs.webkit.org/show_bug.cgi?id=45903
* WebView/WebHTMLRepresentation.mm:
(-[WebHTMLRepresentation elementDoesAutoComplete:]): Use isPasswordField.
(-[WebHTMLRepresentation elementIsPassword:]): Use isPasswordField.
2010-09-16 Patrick Gansterer <paroga@paroga.com>
Reviewed by Darin Adler.
......
......@@ -306,15 +306,14 @@ static HTMLInputElement* inputElementFromDOMElement(DOMElement* element)
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
return inputElement
&& inputElement->isTextField()
&& inputElement->inputType() != HTMLInputElement::PASSWORD
&& !inputElement->isPasswordField()
&& inputElement->autoComplete();
}
- (BOOL)elementIsPassword:(DOMElement *)element
{
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
return inputElement
&& inputElement->inputType() == HTMLInputElement::PASSWORD;
return inputElement && inputElement->isPasswordField();
}
- (DOMElement *)formForElement:(DOMElement *)element
......
2010-09-16 Darin Adler <darin@apple.com>
Reviewed by Andreas Kling.
Reduce use of HTMLInputElement::inputType so we can remove it later
https://bugs.webkit.org/show_bug.cgi?id=45903
* WebCoreSupport/DumpRenderTreeSupportQt.cpp:
(DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId):
Use isPasswordField.
2010-09-16 Robert Hogan <robert@webkit.org>
Reviewed by Antonio Gomes.
......
......@@ -533,9 +533,7 @@ bool DumpRenderTreeSupportQt::elementDoesAutoCompleteForElementWithId(QWebFrame*
if (!inputElement)
return false;
return (inputElement->isTextField()
&& inputElement->inputType() != HTMLInputElement::PASSWORD
&& inputElement->autoComplete());
return inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->autoComplete();
}
void DumpRenderTreeSupportQt::setEditingBehavior(QWebPage* page, const QString& editingBehavior)
......
2010-09-16 Darin Adler <darin@apple.com>
Reviewed by Andreas Kling.
Reduce use of HTMLInputElement::inputType so we can remove it later
https://bugs.webkit.org/show_bug.cgi?id=45903
* WebFrame.cpp:
(WebFrame::elementDoesAutoComplete): Use isPasswordField.
(WebFrame::elementIsPassword): Use isPasswordField.
2010-09-14 Ada Chan <adachan@apple.com>
Reviewed by Adam Roben.
......
......@@ -1185,7 +1185,7 @@ HRESULT WebFrame::elementDoesAutoComplete(IDOMElement *element, BOOL *result)
if (!inputElement)
*result = false;
else
*result = inputElement->isTextField() && inputElement->inputType() != HTMLInputElement::PASSWORD && inputElement->autoComplete();
*result = inputElement->isTextField() && !inputElement->isPasswordField() && inputElement->autoComplete();
return S_OK;
}
......@@ -1390,9 +1390,8 @@ HRESULT WebFrame::controlsInForm(IDOMElement* form, IDOMElement** controls, int*
HRESULT WebFrame::elementIsPassword(IDOMElement *element, bool *result)
{
HTMLInputElement *inputElement = inputElementFromDOMElement(element);
*result = inputElement != 0
&& inputElement->inputType() == HTMLInputElement::PASSWORD;
HTMLInputElement* inputElement = inputElementFromDOMElement(element);
*result = inputElement && inputElement->isPasswordField();
return S_OK;
}
......
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