Commit f8491e23 authored by adele@apple.com's avatar adele@apple.com

2008-07-09 Michelangelo De Simone <m.des@mac.com>

        Reviewed by Adele.

        Added the virtual function Node::isTextControl() in order to simplify text field and textarea checks.

        * css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
        Clean up in PseudoReadOnly and PseudoReadWrite cases removing unnecessary checks and casts in favor of the sole isTextControl() check.
        * dom/Node.h: Added base isTextControl().
        * html/HTMLInputElement.h: Added isTextControl() which wraps HTMLInputElement::isTextField().
        * html/HTMLTextAreaElement.h: Added isTextControl().



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@35073 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 32a5f4cf
2008-07-09 Michelangelo De Simone <m.des@mac.com>
Reviewed by Adele.
Added the virtual function Node::isTextControl() in order to simplify text field and textarea checks.
* css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
Clean up in PseudoReadOnly and PseudoReadWrite cases removing unnecessary checks and casts in favor of the sole isTextControl() check.
* dom/Node.h: Added base isTextControl().
* html/HTMLInputElement.h: Added isTextControl() which wraps HTMLInputElement::isTextField().
* html/HTMLTextAreaElement.h: Added isTextControl().
2008-07-09 Rob Buis <buis@kde.org>
Reviewed by Eric.
......@@ -2055,23 +2055,9 @@ bool CSSStyleSelector::SelectorChecker::checkOneSelector(CSSSelector* sel, Eleme
return !e->isEnabled();
break;
case CSSSelector::PseudoReadOnly:
if (e && e->isControl()) {
if (e->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(e);
return (input->isTextField() && input->isReadOnlyControl());
} else if (e->hasTagName(textareaTag))
return ((static_cast<HTMLTextAreaElement*>(e))->isReadOnlyControl());
}
break;
return e & e->isTextControl() && e->isReadOnlyControl();
case CSSSelector::PseudoReadWrite:
if (e && e->isControl()) {
if (e->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(e);
return (input->isTextField() && !input->isReadOnlyControl());
} else if (e->hasTagName(textareaTag))
return (!(static_cast<HTMLTextAreaElement*>(e))->isReadOnlyControl());
}
break;
return e & e->isTextControl() && !e->isReadOnlyControl();
case CSSSelector::PseudoChecked:
// Even though WinIE allows checked and indeterminate to co-exist, the CSS selector spec says that
// you can't be both checked and indeterminate. We will behave like WinIE behind the scenes and just
......
......@@ -273,6 +273,7 @@ public:
virtual bool isChecked() const { return false; }
virtual bool isIndeterminate() const { return false; }
virtual bool isReadOnlyControl() const { return false; }
virtual bool isTextControl() const { return false; }
virtual bool isContentEditable() const;
virtual bool isContentRichlyEditable() const;
......
......@@ -78,6 +78,8 @@ public:
bool readOnly() const { return isReadOnlyControl(); }
virtual bool isTextControl() const { return isTextField(); }
bool isTextButton() const { return m_type == SUBMIT || m_type == RESET || m_type == BUTTON; }
virtual bool isRadioButton() const { return m_type == RADIO; }
bool isTextField() const { return m_type == TEXT || m_type == PASSWORD || m_type == SEARCH || m_type == ISINDEX; }
......
......@@ -50,6 +50,8 @@ public:
bool readOnly() const { return isReadOnlyControl(); }
virtual bool isTextControl() const { return true; }
int selectionStart();
int selectionEnd();
......
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