https://bugs.webkit.org/show_bug.cgi?id=113273
Reviewed by Kent Tamura.
Element::disabled is about form controls and Element::isEnabledFormControl
is redundant with it, so replace them with a single function
Element::isDisabledFormControl.
Source/WebCore:
No new tests, there should be no behavior change.
* accessibility/AccessibilityListBox.cpp:
(WebCore::AccessibilityListBox::canSetSelectedChildrenAttribute):
* accessibility/AccessibilityListBoxOption.cpp:
(WebCore::AccessibilityListBoxOption::canSetSelectedAttribute):
* accessibility/AccessibilityMenuList.cpp:
(WebCore::AccessibilityMenuList::canSetFocusAttribute):
* accessibility/AccessibilityMenuListOption.cpp:
(WebCore::AccessibilityMenuListOption::isEnabled):
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::isEnabled):
(WebCore::AccessibilityNodeObject::actionElement):
(WebCore::AccessibilityNodeObject::canSetFocusAttribute):
* css/SelectorChecker.cpp:
(WebCore::SelectorChecker::checkOne):
* css/StyleResolver.cpp:
(WebCore::StyleResolver::canShareStyleWithControl):
* dom/Element.cpp:
(WebCore::Element::isDisabledFormControl):
* dom/Element.h:
(Element):
(WebCore::isDisabledFormControl): Add helper function for convenience.
(WebCore):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchSimulatedClick):
* dom/GestureEvent.cpp:
(WebCore::GestureEventDispatchMediator::dispatchEvent):
* dom/MouseEvent.cpp:
(WebCore::MouseEventDispatchMediator::dispatchEvent):
* dom/Node.cpp:
(WebCore::Node::handleLocalEvents):
(WebCore::Node::willRespondToMouseMoveEvents):
(WebCore::Node::willRespondToMouseClickEvents):
(WebCore::Node::willRespondToTouchEvents):
* html/BaseMultipleFieldsDateAndTimeInputType.cpp:
(WebCore::BaseMultipleFieldsDateAndTimeInputType::isEditControlOwnerDisabled):
* html/DOMFormData.cpp:
(WebCore::DOMFormData::DOMFormData):
* html/FileInputType.cpp:
(WebCore::FileInputType::handleDOMActivateEvent):
(WebCore::FileInputType::disabledAttributeChanged):
* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler):
(WebCore::HTMLButtonElement::willRespondToMouseClickEvents):
(WebCore::HTMLButtonElement::isSuccessfulSubmitButton):
* html/HTMLCollection.cpp:
(WebCore::isMatchingElement):
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::updateAncestorDisabledState):
(WebCore::HTMLFormControlElement::isDisabledFormControl):
(WebCore::HTMLFormControlElement::supportsFocus):
* html/HTMLFormControlElement.h:
(HTMLFormControlElement):
(WebCore::HTMLFormControlElement::isDisabledOrReadOnly):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isSuccessfulSubmitButton):
(WebCore::HTMLInputElement::willRespondToMouseClickEvents):
* html/HTMLOptGroupElement.cpp:
(WebCore::HTMLOptGroupElement::isDisabledFormControl):
* html/HTMLOptGroupElement.h:
(HTMLOptGroupElement):
* html/HTMLOptionElement.cpp:
(WebCore::HTMLOptionElement::isDisabledFormControl):
* html/HTMLOptionElement.h:
(HTMLOptionElement):
* html/HTMLPlugInElement.cpp:
(WebCore::HTMLPlugInElement::willRespondToMouseClickEvents):
* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::nextValidIndex):
(WebCore::HTMLSelectElement::updateListBoxSelection):
(WebCore::HTMLSelectElement::recalcListItems):
(WebCore::HTMLSelectElement::appendFormData):
(WebCore::HTMLSelectElement::updateSelectedState):
(WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
(WebCore::HTMLSelectElement::defaultEventHandler):
(WebCore::HTMLSelectElement::optionAtIndex):
* html/ImageInputType.cpp:
(WebCore::ImageInputType::handleDOMActivateEvent):
* html/ResetInputType.cpp:
(WebCore::ResetInputType::handleDOMActivateEvent):
* html/SubmitInputType.cpp:
(WebCore::SubmitInputType::handleDOMActivateEvent):
* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::isDisabledFormControl):
(WebCore::SliderThumbElement::defaultEventHandler):
(WebCore::SliderThumbElement::willRespondToMouseMoveEvents):
(WebCore::SliderThumbElement::willRespondToMouseClickEvents):
* html/shadow/SliderThumbElement.h:
(SliderThumbElement):
* html/shadow/SpinButtonElement.h:
* html/shadow/TextFieldDecorationElement.cpp:
(WebCore::TextFieldDecorationElement::updateImage):
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* page/DragController.cpp:
(WebCore::DragController::tryDocumentDrag):
(WebCore::DragController::concludeEditDrag):
* rendering/RenderListBox.cpp:
(WebCore::RenderListBox::addFocusRingRects):
(WebCore::RenderListBox::paintItemForeground):
* rendering/RenderMenuList.cpp:
(WebCore::RenderMenuList::itemIsEnabled):
* rendering/RenderTextControl.cpp:
(WebCore::updateUserModifyProperty):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::isEnabled):
* rendering/RenderThemeMac.mm:
(WebCore::getMediaUIPartStateFlags):
* rendering/RenderThemeMacShared.mm:
(WebCore::RenderThemeMacShared::adjustMenuListStyle):
(WebCore::RenderThemeMacShared::paintSearchFieldCancelButton):
* rendering/RenderThemeSafari.cpp:
(WebCore::RenderThemeSafari::adjustMenuListStyle):
Source/WebKit/blackberry:
* WebCoreSupport/CredentialTransformData.cpp:
(WebCore::CredentialTransformData::findPasswordFormFields):
* WebKitSupport/DOMSupport.cpp:
(BlackBerry::WebKit::DOMSupport::isTextBasedContentEditableElement):
* WebKitSupport/InputHandler.cpp:
(BlackBerry::WebKit::InputHandler::openSelectPopup):
Source/WebKit/chromium:
* src/WebFormControlElement.cpp:
(WebKit::WebFormControlElement::isEnabled):
* src/WebOptionElement.cpp:
(WebKit::WebOptionElement::isEnabled):
* src/WebPasswordFormUtils.cpp:
(WebKit::findPasswordFormFields):
* src/WebSearchableFormData.cpp:
(HTMLNames::findSuitableSearchInputElement):
(HTMLNames::buildSearchString):
Source/WebKit/win:
* DOMHTMLClasses.cpp:
(DOMHTMLInputElement::disabled):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147135
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2013-03-28 Matt Falkenhagen <falken@chromium.org>
+
+ Refactoring: Replace Element::disabled and isEnabledFormControl with isDisabledFormControl
+ https://bugs.webkit.org/show_bug.cgi?id=113273
+
+ Reviewed by Kent Tamura.
+
+ Element::disabled is about form controls and Element::isEnabledFormControl
+ is redundant with it, so replace them with a single function
+ Element::isDisabledFormControl.
+
+ No new tests, there should be no behavior change.
+
+ * accessibility/AccessibilityListBox.cpp:
+ (WebCore::AccessibilityListBox::canSetSelectedChildrenAttribute):
+ * accessibility/AccessibilityListBoxOption.cpp:
+ (WebCore::AccessibilityListBoxOption::canSetSelectedAttribute):
+ * accessibility/AccessibilityMenuList.cpp:
+ (WebCore::AccessibilityMenuList::canSetFocusAttribute):
+ * accessibility/AccessibilityMenuListOption.cpp:
+ (WebCore::AccessibilityMenuListOption::isEnabled):
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::isEnabled):
+ (WebCore::AccessibilityNodeObject::actionElement):
+ (WebCore::AccessibilityNodeObject::canSetFocusAttribute):
+ * css/SelectorChecker.cpp:
+ (WebCore::SelectorChecker::checkOne):
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::canShareStyleWithControl):
+ * dom/Element.cpp:
+ (WebCore::Element::isDisabledFormControl):
+ * dom/Element.h:
+ (Element):
+ (WebCore::isDisabledFormControl): Add helper function for convenience.
+ (WebCore):
+ * dom/EventDispatcher.cpp:
+ (WebCore::EventDispatcher::dispatchSimulatedClick):
+ * dom/GestureEvent.cpp:
+ (WebCore::GestureEventDispatchMediator::dispatchEvent):
+ * dom/MouseEvent.cpp:
+ (WebCore::MouseEventDispatchMediator::dispatchEvent):
+ * dom/Node.cpp:
+ (WebCore::Node::handleLocalEvents):
+ (WebCore::Node::willRespondToMouseMoveEvents):
+ (WebCore::Node::willRespondToMouseClickEvents):
+ (WebCore::Node::willRespondToTouchEvents):
+ * html/BaseMultipleFieldsDateAndTimeInputType.cpp:
+ (WebCore::BaseMultipleFieldsDateAndTimeInputType::isEditControlOwnerDisabled):
+ * html/DOMFormData.cpp:
+ (WebCore::DOMFormData::DOMFormData):
+ * html/FileInputType.cpp:
+ (WebCore::FileInputType::handleDOMActivateEvent):
+ (WebCore::FileInputType::disabledAttributeChanged):
+ * html/HTMLButtonElement.cpp:
+ (WebCore::HTMLButtonElement::defaultEventHandler):
+ (WebCore::HTMLButtonElement::willRespondToMouseClickEvents):
+ (WebCore::HTMLButtonElement::isSuccessfulSubmitButton):
+ * html/HTMLCollection.cpp:
+ (WebCore::isMatchingElement):
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::updateAncestorDisabledState):
+ (WebCore::HTMLFormControlElement::isDisabledFormControl):
+ (WebCore::HTMLFormControlElement::supportsFocus):
+ * html/HTMLFormControlElement.h:
+ (HTMLFormControlElement):
+ (WebCore::HTMLFormControlElement::isDisabledOrReadOnly):
+ * html/HTMLInputElement.cpp:
+ (WebCore::HTMLInputElement::isSuccessfulSubmitButton):
+ (WebCore::HTMLInputElement::willRespondToMouseClickEvents):
+ * html/HTMLOptGroupElement.cpp:
+ (WebCore::HTMLOptGroupElement::isDisabledFormControl):
+ * html/HTMLOptGroupElement.h:
+ (HTMLOptGroupElement):
+ * html/HTMLOptionElement.cpp:
+ (WebCore::HTMLOptionElement::isDisabledFormControl):
+ * html/HTMLOptionElement.h:
+ (HTMLOptionElement):
+ * html/HTMLPlugInElement.cpp:
+ (WebCore::HTMLPlugInElement::willRespondToMouseClickEvents):
+ * html/HTMLSelectElement.cpp:
+ (WebCore::HTMLSelectElement::nextValidIndex):
+ (WebCore::HTMLSelectElement::updateListBoxSelection):
+ (WebCore::HTMLSelectElement::recalcListItems):
+ (WebCore::HTMLSelectElement::appendFormData):
+ (WebCore::HTMLSelectElement::updateSelectedState):
+ (WebCore::HTMLSelectElement::listBoxDefaultEventHandler):
+ (WebCore::HTMLSelectElement::defaultEventHandler):
+ (WebCore::HTMLSelectElement::optionAtIndex):
+ * html/ImageInputType.cpp:
+ (WebCore::ImageInputType::handleDOMActivateEvent):
+ * html/ResetInputType.cpp:
+ (WebCore::ResetInputType::handleDOMActivateEvent):
+ * html/SubmitInputType.cpp:
+ (WebCore::SubmitInputType::handleDOMActivateEvent):
+ * html/shadow/SliderThumbElement.cpp:
+ (WebCore::SliderThumbElement::isDisabledFormControl):
+ (WebCore::SliderThumbElement::defaultEventHandler):
+ (WebCore::SliderThumbElement::willRespondToMouseMoveEvents):
+ (WebCore::SliderThumbElement::willRespondToMouseClickEvents):
+ * html/shadow/SliderThumbElement.h:
+ (SliderThumbElement):
+ * html/shadow/SpinButtonElement.h:
+ * html/shadow/TextFieldDecorationElement.cpp:
+ (WebCore::TextFieldDecorationElement::updateImage):
+ * loader/FormSubmission.cpp:
+ (WebCore::FormSubmission::create):
+ * page/DragController.cpp:
+ (WebCore::DragController::tryDocumentDrag):
+ (WebCore::DragController::concludeEditDrag):
+ * rendering/RenderListBox.cpp:
+ (WebCore::RenderListBox::addFocusRingRects):
+ (WebCore::RenderListBox::paintItemForeground):
+ * rendering/RenderMenuList.cpp:
+ (WebCore::RenderMenuList::itemIsEnabled):
+ * rendering/RenderTextControl.cpp:
+ (WebCore::updateUserModifyProperty):
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::isEnabled):
+ * rendering/RenderThemeMac.mm:
+ (WebCore::getMediaUIPartStateFlags):
+ * rendering/RenderThemeMacShared.mm:
+ (WebCore::RenderThemeMacShared::adjustMenuListStyle):
+ (WebCore::RenderThemeMacShared::paintSearchFieldCancelButton):
+ * rendering/RenderThemeSafari.cpp:
+ (WebCore::RenderThemeSafari::adjustMenuListStyle):
+
2013-03-28 Brady Eidson <beidson@apple.com>
Remove workaround for <rdar://problem/5321972>.
if (!selectNode)
return false;
- return !toHTMLSelectElement(selectNode)->disabled();
+ return !toHTMLSelectElement(selectNode)->isDisabledFormControl();
}
void AccessibilityListBox::addChildren()
if (!m_optionElement->hasTagName(optionTag))
return false;
- if (m_optionElement->disabled())
+ if (m_optionElement->isDisabledFormControl())
return false;
HTMLSelectElement* selectElement = listBoxOptionParentNode();
- if (selectElement && selectElement->disabled())
+ if (selectElement && selectElement->isDisabledFormControl())
return false;
return true;
if (!node())
return false;
- return toElement(node())->isEnabledFormControl();
+ return !toElement(node())->isDisabledFormControl();
}
void AccessibilityMenuList::didUpdateActiveOption(int optionIndex)
bool AccessibilityMenuListOption::isEnabled() const
{
- // disabled() returns true if the parent <select> element is disabled,
+ // isDisabledFormControl() returns true if the parent <select> element is disabled,
// which we don't want.
return !static_cast<HTMLOptionElement*>(m_element.get())->ownElementDisabled();
}
if (!node || !node->isElementNode())
return true;
- return toElement(node)->isEnabledFormControl();
+ return !toElement(node)->isDisabledFormControl();
}
bool AccessibilityNodeObject::isIndeterminate() const
if (node->hasTagName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(node);
- if (!input->disabled() && (isCheckboxOrRadio() || input->isTextButton()))
+ if (!input->isDisabledFormControl() && (isCheckboxOrRadio() || input->isTextButton()))
return input;
} else if (node->hasTagName(buttonTag))
return toElement(node);
if (!node)
return false;
- if (node->isElementNode() && !toElement(node)->isEnabledFormControl())
+ if (isDisabledFormControl(node))
return false;
return node->supportsFocus();
break;
case CSSSelector::PseudoEnabled:
if (element && (element->isFormControlElement() || element->hasTagName(optionTag) || element->hasTagName(optgroupTag)))
- return element->isEnabledFormControl();
+ return !element->isDisabledFormControl();
break;
case CSSSelector::PseudoFullPageMedia:
return element && element->document() && element->document()->isMediaDocument();
return element && element->isDefaultButtonForForm();
case CSSSelector::PseudoDisabled:
if (element && (element->isFormControlElement() || element->hasTagName(optionTag) || element->hasTagName(optgroupTag)))
- return !element->isEnabledFormControl();
+ return element->isDisabledFormControl();
break;
case CSSSelector::PseudoReadOnly:
return element && element->matchesReadOnlyPseudoClass();
if (thisInputElement->isRequired() != otherInputElement->isRequired())
return false;
- if (element->isEnabledFormControl() != state.element()->isEnabledFormControl())
+ if (element->isDisabledFormControl() != state.element()->isDisabledFormControl())
return false;
if (element->isDefaultButtonForForm() != state.element()->isDefaultButtonForForm())
{
}
-bool Element::disabled() const
+bool Element::isDisabledFormControl() const
{
#if ENABLE(DIALOG_ELEMENT)
// FIXME: disabled and inert are separate concepts in the spec, but now we treat them as the same.
#endif
virtual bool isFormControlElement() const { return false; }
- virtual bool isEnabledFormControl() const { return true; }
virtual bool isSpinButtonElement() const { return false; }
virtual bool isTextFormControl() const { return false; }
virtual bool isOptionalFormControl() const { return false; }
// Used for disabled form elements; if true, prevents mouse events from being dispatched
// to event listeners, and prevents DOMActivate events from being sent at all.
- virtual bool disabled() const;
+ virtual bool isDisabledFormControl() const;
#if ENABLE(DIALOG_ELEMENT)
bool isInert() const;
// This will catch anyone doing an unnecessary cast.
void toElement(const Element*);
+inline bool isDisabledFormControl(const Node* node)
+{
+ return node->isElementNode() && toElement(node)->isDisabledFormControl();
+}
+
inline bool Node::hasTagName(const QualifiedName& name) const
{
return isElementNode() && toElement(this)->hasTagName(name);
void EventDispatcher::dispatchSimulatedClick(Node* node, Event* underlyingEvent, SimulatedClickMouseEventOptions mouseEventOptions, SimulatedClickVisualOptions visualOptions)
{
- if (node->isElementNode() && toElement(node)->disabled())
+ if (isDisabledFormControl(node))
return;
if (!gNodesDispatchingSimulatedClicks)
bool GestureEventDispatchMediator::dispatchEvent(EventDispatcher* dispatcher) const
{
- if (dispatcher->node()->isElementNode() && toElement(dispatcher->node())->disabled())
+ if (isDisabledFormControl(dispatcher->node()))
return true;
dispatcher->dispatch();
return dispatcher->dispatch();
}
- if (dispatcher->node()->isElementNode() && toElement(dispatcher->node())->disabled()) // Don't even send DOM events for disabled controls..
+ if (isDisabledFormControl(dispatcher->node()))
return false;
if (event()->type().isEmpty())
if (!hasEventTargetData())
return;
- if (isElementNode() && toElement(this)->disabled() && event->isMouseEvent())
+ if (isDisabledFormControl(this) && event->isMouseEvent())
return;
fireEventListeners(event);
bool Node::willRespondToMouseMoveEvents()
{
- if (isElementNode() && toElement(this)->disabled())
+ if (isDisabledFormControl(this))
return false;
return hasEventListeners(eventNames().mousemoveEvent) || hasEventListeners(eventNames().mouseoverEvent) || hasEventListeners(eventNames().mouseoutEvent);
}
bool Node::willRespondToMouseClickEvents()
{
- if (isElementNode() && toElement(this)->disabled())
+ if (isDisabledFormControl(this))
return false;
return isContentEditable(UserSelectAllIsAlwaysNonEditable) || hasEventListeners(eventNames().mouseupEvent) || hasEventListeners(eventNames().mousedownEvent) || hasEventListeners(eventNames().clickEvent) || hasEventListeners(eventNames().DOMActivateEvent);
}
bool Node::willRespondToTouchEvents()
{
#if ENABLE(TOUCH_EVENTS)
- if (isElementNode() && toElement(this)->disabled())
+ if (isDisabledFormControl(this))
return false;
return hasEventListeners(eventNames().touchstartEvent) || hasEventListeners(eventNames().touchmoveEvent) || hasEventListeners(eventNames().touchcancelEvent) || hasEventListeners(eventNames().touchendEvent);
#else
bool BaseMultipleFieldsDateAndTimeInputType::isEditControlOwnerDisabled() const
{
- return element()->disabled();
+ return element()->isDisabledFormControl();
}
bool BaseMultipleFieldsDateAndTimeInputType::isEditControlOwnerReadOnly() const
for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
FormAssociatedElement* element = form->associatedElements()[i];
- if (!toHTMLElement(element)->disabled())
+ if (!toHTMLElement(element)->isDisabledFormControl())
element->appendFormData(*this, true);
}
}
void FileInputType::handleDOMActivateEvent(Event* event)
{
- if (element()->disabled())
+ if (element()->isDisabledFormControl())
return;
if (!ScriptController::processingUserGesture())
ASSERT(element()->shadow());
UploadButtonElement* button = static_cast<UploadButtonElement*>(element()->userAgentShadowRoot()->firstChild());
if (button)
- button->setBooleanAttribute(disabledAttr, element()->disabled());
+ button->setBooleanAttribute(disabledAttr, element()->isDisabledFormControl());
}
void FileInputType::multipleAttributeChanged()
void HTMLButtonElement::defaultEventHandler(Event* event)
{
- if (event->type() == eventNames().DOMActivateEvent && !disabled()) {
+ if (event->type() == eventNames().DOMActivateEvent && !isDisabledFormControl()) {
if (form() && m_type == SUBMIT) {
m_isActivatedSubmit = true;
form()->prepareForSubmission(event);
bool HTMLButtonElement::willRespondToMouseClickEvents()
{
- if (!disabled() && form() && (m_type == SUBMIT || m_type == RESET))
+ if (!isDisabledFormControl() && form() && (m_type == SUBMIT || m_type == RESET))
return true;
return HTMLFormControlElement::willRespondToMouseClickEvents();
}
{
// HTML spec says that buttons must have names to be considered successful.
// However, other browsers do not impose this constraint.
- return m_type == SUBMIT && !disabled();
+ return m_type == SUBMIT && !isDisabledFormControl();
}
bool HTMLButtonElement::isActivatedSubmit() const
case DataListOptions:
if (element->hasLocalName(optionTag)) {
HTMLOptionElement* option = static_cast<HTMLOptionElement*>(element);
- if (!option->disabled() && !option->value().isEmpty())
+ if (!option->isDisabledFormControl() && !option->value().isEmpty())
return true;
}
return false;
break;
}
}
- m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->disabled() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend())) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled;
+ m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->isDisabledFormControl() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend())) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled;
}
void HTMLFormControlElement::ancestorDisabledStateWasChanged()
HTMLElement::dispatchInputEvent();
}
-bool HTMLFormControlElement::disabled() const
+bool HTMLFormControlElement::isDisabledFormControl() const
{
if (m_disabled)
return true;
updateAncestorDisabledState();
if (m_ancestorDisabledState == AncestorDisabledStateDisabled)
return true;
- return HTMLElement::disabled();
+ return HTMLElement::isDisabledFormControl();
}
bool HTMLFormControlElement::isRequired() const
bool HTMLFormControlElement::supportsFocus() const
{
- return !disabled();
+ return !isDisabledFormControl();
}
bool HTMLFormControlElement::isFocusable() const
virtual void dispatchFormControlChangeEvent();
virtual void dispatchFormControlInputEvent();
- virtual bool disabled() const;
+ virtual bool isDisabledFormControl() const OVERRIDE;
virtual bool isFocusable() const;
virtual bool isEnumeratable() const { return false; }
const AtomicString& type() const { return formControlType(); }
virtual const AtomicString& formControlType() const OVERRIDE = 0;
- virtual bool isEnabledFormControl() const { return !disabled(); }
virtual bool canTriggerImplicitSubmission() const { return false; }
virtual void setCustomValidity(const String&) OVERRIDE;
bool isReadOnly() const { return m_isReadOnly; }
- bool isDisabledOrReadOnly() const { return disabled() || m_isReadOnly; }
+ bool isDisabledOrReadOnly() const { return isDisabledFormControl() || m_isReadOnly; }
bool hasAutofocused() { return m_hasAutofocused; }
void setAutofocused() { m_hasAutofocused = true; }
{
// HTML spec says that buttons must have names to be considered successful.
// However, other browsers do not impose this constraint. So we do not.
- return !disabled() && m_inputType->canBeSuccessfulSubmitButton();
+ return !isDisabledFormControl() && m_inputType->canBeSuccessfulSubmitButton();
}
bool HTMLInputElement::isActivatedSubmit() const
bool HTMLInputElement::willRespondToMouseClickEvents()
{
// FIXME: Consider implementing willRespondToMouseClickEvents() in InputType if more accurate results are necessary.
- if (!disabled())
+ if (!isDisabledFormControl())
return true;
return HTMLTextFormControlElement::willRespondToMouseClickEvents();
return adoptRef(new HTMLOptGroupElement(tagName, document));
}
-bool HTMLOptGroupElement::disabled() const
+bool HTMLOptGroupElement::isDisabledFormControl() const
{
return fastHasAttribute(disabledAttr);
}
public:
static PassRefPtr<HTMLOptGroupElement> create(const QualifiedName&, Document*);
- virtual bool disabled() const OVERRIDE;
+ virtual bool isDisabledFormControl() const OVERRIDE;
HTMLSelectElement* ownerSelectElement() const;
String groupLabelText() const;
virtual const AtomicString& formControlType() const;
virtual bool supportsFocus() const;
virtual bool isFocusable() const;
- virtual bool isEnabledFormControl() const OVERRIDE { return !disabled(); }
virtual void parseAttribute(const QualifiedName&, const AtomicString&) OVERRIDE;
virtual bool rendererIsNeeded(const NodeRenderingContext&) { return false; }
virtual void attach();
return text();
}
-bool HTMLOptionElement::disabled() const
+bool HTMLOptionElement::isDisabledFormControl() const
{
if (ownElementDisabled())
return true;
return false;
HTMLElement* parentElement = static_cast<HTMLElement*>(parentNode());
- return parentElement->hasTagName(optgroupTag) && parentElement->disabled();
+ return parentElement->hasTagName(optgroupTag) && parentElement->isDisabledFormControl();
}
Node::InsertionNotificationRequest HTMLOptionElement::insertedInto(ContainerNode* insertionPoint)
String label() const;
void setLabel(const String&);
- virtual bool isEnabledFormControl() const OVERRIDE { return !disabled(); }
bool ownElementDisabled() const { return m_disabled; }
- virtual bool disabled() const;
+ virtual bool isDisabledFormControl() const OVERRIDE;
String textIndentedToRespectGroupLabel() const;
bool HTMLPlugInElement::willRespondToMouseClickEvents()
{
- if (disabled())
+ if (isDisabledFormControl())
return false;
RenderObject* r = renderer();
if (!r)
int size = listItems.size();
for (listIndex += direction; listIndex >= 0 && listIndex < size; listIndex += direction) {
--skip;
- if (!listItems[listIndex]->disabled() && listItems[listIndex]->hasTagName(optionTag)) {
+ if (!listItems[listIndex]->isDisabledFormControl() && listItems[listIndex]->hasTagName(optionTag)) {
lastGoodIndex = listIndex;
if (skip <= 0)
break;
const Vector<HTMLElement*>& items = listItems();
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
- if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->disabled())
+ if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->isDisabledFormControl())
continue;
if (i >= start && i <= end)
if (foundSelected)
foundSelected->setSelectedState(false);
foundSelected = option;
- } else if (m_size <= 1 && !foundSelected && !option->disabled()) {
+ } else if (m_size <= 1 && !foundSelected && !option->isDisabledFormControl()) {
foundSelected = option;
foundSelected->setSelectedState(true);
}
for (unsigned i = 0; i < items.size(); ++i) {
HTMLElement* element = items[i];
- if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected() && !toHTMLOptionElement(element)->disabled()) {
+ if (element->hasTagName(optionTag) && toHTMLOptionElement(element)->selected() && !toHTMLOptionElement(element)->isDisabledFormControl()) {
list.appendData(name, toHTMLOptionElement(element)->value());
successful = true;
}
setActiveSelectionAnchorIndex(selectedIndex());
// Set the selection state of the clicked option.
- if (clickedElement->hasTagName(optionTag) && !toHTMLOptionElement(clickedElement)->disabled())
+ if (clickedElement->hasTagName(optionTag) && !toHTMLOptionElement(clickedElement)->isDisabledFormControl())
toHTMLOptionElement(clickedElement)->setSelectedState(true);
// If there was no selectedIndex() for the previous initialization, or If
IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize(localOffset));
if (listIndex >= 0) {
- if (!disabled()) {
+ if (!isDisabledFormControl()) {
#if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
updateSelectedState(listIndex, mouseEvent->metaKey(), mouseEvent->shiftKey());
#else
IntPoint localOffset = roundedIntPoint(renderer()->absoluteToLocal(mouseEvent->absoluteLocation(), UseTransforms));
int listIndex = toRenderListBox(renderer())->listIndexAtOffset(toIntSize(localOffset));
if (listIndex >= 0) {
- if (!disabled()) {
+ if (!isDisabledFormControl()) {
if (m_multiple) {
// Only extend selection if there is something selected.
if (m_activeSelectionAnchorIndex < 0)
if (!renderer())
return;
- if (disabled()) {
+ if (isDisabledFormControl()) {
HTMLFormControlElementWithState::defaultEventHandler(event);
return;
}
const Vector<HTMLElement*>& items = listItems();
HTMLElement* element = items[index];
- if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->disabled())
+ if (!element->hasTagName(optionTag) || toHTMLOptionElement(element)->isDisabledFormControl())
return String();
return toHTMLOptionElement(element)->textIndentedToRespectGroupLabel();
}
void ImageInputType::handleDOMActivateEvent(Event* event)
{
RefPtr<HTMLInputElement> element = this->element();
- if (element->disabled() || !element->form())
+ if (element->isDisabledFormControl() || !element->form())
return;
element->setActivatedSubmit(true);
if (event->underlyingEvent() && event->underlyingEvent()->isMouseEvent()) {
void ResetInputType::handleDOMActivateEvent(Event* event)
{
- if (element()->disabled() || !element()->form())
+ if (element()->isDisabledFormControl() || !element()->form())
return;
element()->form()->reset();
event->setDefaultHandled();
void SubmitInputType::handleDOMActivateEvent(Event* event)
{
RefPtr<HTMLInputElement> element = this->element();
- if (element->disabled() || !element->form())
+ if (element->isDisabledFormControl() || !element->form())
return;
element->setActivatedSubmit(true);
element->form()->prepareForSubmission(event); // Event handlers can run.
return new (arena) RenderSliderThumb(this);
}
-bool SliderThumbElement::disabled() const
+bool SliderThumbElement::isDisabledFormControl() const
{
- return hostInput()->disabled();
-}
-
-bool SliderThumbElement::isEnabledFormControl() const
-{
- return !disabled();
+ return hostInput()->isDisabledFormControl();
}
bool SliderThumbElement::matchesReadOnlyPseudoClass() const
SliderThumbElement(Document*);
virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
virtual PassRefPtr<Element> cloneElementWithoutAttributesAndChildren();
- virtual bool disabled() const OVERRIDE;
- virtual bool isEnabledFormControl() const OVERRIDE;
+ virtual bool isDisabledFormControl() const OVERRIDE;
virtual bool matchesReadOnlyPseudoClass() const OVERRIDE;
virtual bool matchesReadWritePseudoClass() const OVERRIDE;
virtual Node* focusDelegate();
virtual const AtomicString& shadowPseudoId() const;
virtual void detach();
virtual bool isSpinButtonElement() const { return true; }
- virtual bool disabled() const OVERRIDE { return shadowHost() && shadowHost()->disabled(); }
- virtual bool isEnabledFormControl() const OVERRIDE { return !disabled(); }
+ virtual bool isDisabledFormControl() const OVERRIDE { return shadowHost() && shadowHost()->isDisabledFormControl(); }
virtual bool matchesReadOnlyPseudoClass() const OVERRIDE;
virtual bool matchesReadWritePseudoClass() const OVERRIDE;
virtual void defaultEventHandler(Event*);
return;
RenderImageResource* resource = toRenderImage(renderer())->imageResource();
CachedImage* image;
- if (hostInput()->disabled())
+ if (hostInput()->isDisabledFormControl())
image = m_textFieldDecorator->imageForDisabledState();
else if (hostInput()->isReadOnly())
image = m_textFieldDecorator->imageForReadonlyState();
for (unsigned i = 0; i < form->associatedElements().size(); ++i) {
FormAssociatedElement* control = form->associatedElements()[i];
HTMLElement* element = toHTMLElement(control);
- if (!element->disabled())
+ if (!element->isDisabledFormControl())
control->appendFormData(*domFormData, isMultiPartForm);
if (element->hasLocalName(inputTag)) {
HTMLInputElement* input = static_cast<HTMLInputElement*>(control);
unsigned numberOfFiles = dragData->numberOfFiles();
if (m_fileInputElementUnderMouse) {
- if (m_fileInputElementUnderMouse->disabled())
+ if (m_fileInputElementUnderMouse->isDisabledFormControl())
dragSession.numberOfItemsToBeAccepted = 0;
else if (m_fileInputElementUnderMouse->multiple())
dragSession.numberOfItemsToBeAccepted = numberOfFiles;
// fileInput should be the element we hit tested for, unless it was made
// display:none in a drop event handler.
ASSERT(fileInput == element || !fileInput->renderer());
- if (fileInput->disabled())
+ if (fileInput->isDisabledFormControl())
return false;
return fileInput->receiveDroppedFiles(dragData);
const Vector<HTMLElement*>& listItems = select->listItems();
for (int i = 0; i < size; ++i) {
HTMLElement* element = listItems[i];
- if (element->hasTagName(optionTag) && !toHTMLOptionElement(element)->disabled()) {
+ if (element->hasTagName(optionTag) && !element->isDisabledFormControl()) {
rects.append(pixelSnappedIntRect(itemBoundingBoxRect(additionalOffset, i)));
return;
}
if (frame()->selection()->isFocusedAndActive() && document()->focusedNode() == node())
textColor = theme()->activeListBoxSelectionForegroundColor();
// Honor the foreground color for disabled items
- else if (!element->disabled() && !select->disabled())
+ else if (!element->isDisabledFormControl() && !select->isDisabledFormControl())
textColor = theme()->inactiveListBoxSelectionForegroundColor();
}
bool groupEnabled = true;
if (Element* parentElement = element->parentElement()) {
if (parentElement->hasTagName(optgroupTag))
- groupEnabled = !static_cast<HTMLOptGroupElement*>(parentElement)->disabled();
+ groupEnabled = !parentElement->isDisabledFormControl();
}
if (!groupEnabled)
return false;
- return element->isEnabledFormControl();
+ return !element->isDisabledFormControl();
}
PopupMenuStyle RenderMenuList::itemStyle(unsigned listIndex) const
static inline bool updateUserModifyProperty(Node* node, RenderStyle* style)
{
- bool isEnabled = true;
+ bool isDisabled = false;
bool isReadOnlyControl = false;
if (node->isElementNode()) {
Element* element = toElement(node);
- isEnabled = element->isEnabledFormControl();
+ isDisabled = element->isDisabledFormControl();
isReadOnlyControl = element->isTextFormControl() && toHTMLTextFormControlElement(element)->isReadOnly();
}
- style->setUserModify((isReadOnlyControl || !isEnabled) ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY);
- return !isEnabled;
+ style->setUserModify((isReadOnlyControl || isDisabled) ? READ_ONLY : READ_WRITE_PLAINTEXT_ONLY);
+ return isDisabled;
}
void RenderTextControl::adjustInnerTextStyle(const RenderStyle* startStyle, RenderStyle* textBlockStyle) const
Node* node = o->node();
if (!node || !node->isElementNode())
return true;
- return toElement(node)->isEnabledFormControl();
+ return !toElement(node)->isDisabledFormControl();
}
bool RenderTheme::isFocused(const RenderObject* o) const
{
unsigned flags = 0;
- if (node->isElementNode() && toElement(node)->disabled())
+ if (isDisabledFormControl(node))
flags |= MediaUIPartDisabledFlag;
else if (node->active())
flags |= MediaUIPartPressedFlag;
// Set the foreground color to black or gray when we have the aqua look.
// Cast to RGB32 is to work around a compiler bug.
- style->setColor(e && e->isEnabledFormControl() ? static_cast<RGBA32>(Color::black) : Color::darkGray);
+ style->setColor(e && !e->isDisabledFormControl() ? static_cast<RGBA32>(Color::black) : Color::darkGray);
// Set the button's vertical size.
setSizeFromFont(style, menuListButtonSizes());
NSSearchFieldCell* search = this->search();
- if (input->isEnabledFormControl() && (input->isTextFormControl() && !toHTMLTextFormControlElement(input)->isReadOnly())) {
+ if (!input->isDisabledFormControl() && (input->isTextFormControl() && !toHTMLTextFormControlElement(input)->isReadOnly())) {
updateActiveState([search cancelButtonCell], o);
updatePressedState([search cancelButtonCell], o);
}
// Set the foreground color to black or gray when we have the aqua look.
// Cast to RGB32 is to work around a compiler bug.
- style->setColor(e && e->isEnabledFormControl() ? static_cast<RGBA32>(Color::black) : Color::darkGray);
+ style->setColor(e && !e->isDisabledFormControl() ? static_cast<RGBA32>(Color::black) : Color::darkGray);
// Set the button's vertical size.
setButtonSize(style);
+2013-03-28 Matt Falkenhagen <falken@chromium.org>
+
+ Refactoring: Replace Element::disabled and isEnabledFormControl with isDisabledFormControl
+ https://bugs.webkit.org/show_bug.cgi?id=113273
+
+ Reviewed by Kent Tamura.
+
+ Element::disabled is about form controls and Element::isEnabledFormControl
+ is redundant with it, so replace them with a single function
+ Element::isDisabledFormControl.
+
+ * WebCoreSupport/CredentialTransformData.cpp:
+ (WebCore::CredentialTransformData::findPasswordFormFields):
+ * WebKitSupport/DOMSupport.cpp:
+ (BlackBerry::WebKit::DOMSupport::isTextBasedContentEditableElement):
+ * WebKitSupport/InputHandler.cpp:
+ (BlackBerry::WebKit::InputHandler::openSelectPopup):
+
2013-03-27 Eli Fidler <efidler@blackberry.com>
[BlackBerry] Show compositing on the Inspector timeline properly
continue;
HTMLInputElement* inputElement = formElement->toInputElement();
- if (!inputElement->isEnabledFormControl())
+ if (inputElement->isDisabledFormControl())
continue;
if ((passwords.size() < maxPasswords)
continue;
HTMLInputElement* inputElement = formElement->toInputElement();
- if (!inputElement->isEnabledFormControl())
+ if (inputElement->isDisabledFormControl())
continue;
// Various input types such as text, url, email can be a username field.
if (!element)
return false;
- if (element->isReadOnlyNode() || !element->isEnabledFormControl())
+ if (element->isReadOnlyNode() || element->isDisabledFormControl())
return false;
if (isPopupInputField(element))
bool InputHandler::openSelectPopup(HTMLSelectElement* select)
{
- if (!select || select->disabled())
+ if (!select || select->isDisabledFormControl())
return false;
// If there's no view, do nothing and return.
if (listItems[i]->hasTagName(HTMLNames::optionTag)) {
HTMLOptionElement* option = static_cast<HTMLOptionElement*>(listItems[i]);
labels[i] = option->textIndentedToRespectGroupLabel();
- enableds[i] = option->disabled() ? 0 : 1;
+ enableds[i] = option->isDisabledFormControl() ? 0 : 1;
selecteds[i] = option->selected();
itemTypes[i] = option->parentNode() && option->parentNode()->hasTagName(HTMLNames::optgroupTag) ? TypeOptionInGroup : TypeOption;
} else if (listItems[i]->hasTagName(HTMLNames::optgroupTag)) {
HTMLOptGroupElement* optGroup = static_cast<HTMLOptGroupElement*>(listItems[i]);
labels[i] = optGroup->groupLabelText();
- enableds[i] = optGroup->disabled() ? 0 : 1;
+ enableds[i] = optGroup->isDisabledFormControl() ? 0 : 1;
selecteds[i] = false;
itemTypes[i] = TypeGroup;
} else if (listItems[i]->hasTagName(HTMLNames::hrTag)) {
+2013-03-28 Matt Falkenhagen <falken@chromium.org>
+
+ Refactoring: Replace Element::disabled and isEnabledFormControl with isDisabledFormControl
+ https://bugs.webkit.org/show_bug.cgi?id=113273
+
+ Reviewed by Kent Tamura.
+
+ Element::disabled is about form controls and Element::isEnabledFormControl
+ is redundant with it, so replace them with a single function
+ Element::isDisabledFormControl.
+
+ * src/WebFormControlElement.cpp:
+ (WebKit::WebFormControlElement::isEnabled):
+ * src/WebOptionElement.cpp:
+ (WebKit::WebOptionElement::isEnabled):
+ * src/WebPasswordFormUtils.cpp:
+ (WebKit::findPasswordFormFields):
+ * src/WebSearchableFormData.cpp:
+ (HTMLNames::findSuitableSearchInputElement):
+ (HTMLNames::buildSearchString):
+
2013-03-27 Keishi Hattori <keishi@webkit.org>
[Chromium] Enable touch events in PagePopup
bool WebFormControlElement::isEnabled() const
{
- return constUnwrap<HTMLFormControlElement>()->isEnabledFormControl();
+ return !constUnwrap<HTMLFormControlElement>()->isDisabledFormControl();
}
bool WebFormControlElement::isReadOnly() const
bool WebOptionElement::isEnabled() const
{
- return !(constUnwrap<HTMLOptionElement>()->disabled());
+ return !(constUnwrap<HTMLOptionElement>()->isDisabledFormControl());
}
WebOptionElement::WebOptionElement(const PassRefPtr<HTMLOptionElement>& elem)
continue;
HTMLInputElement* inputElement = toHTMLInputElement(formElement);
- if (!inputElement->isEnabledFormControl())
+ if (inputElement->isDisabledFormControl())
continue;
if ((fields->passwords.size() < maxPasswords)
HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(*i);
- if (formElement->disabled() || formElement->name().isNull())
+ if (formElement->isDisabledFormControl() || formElement->name().isNull())
continue;
if (!IsInDefaultState(formElement) || formElement->hasTagName(HTMLNames::textareaTag))
HTMLFormControlElement* formElement = static_cast<HTMLFormControlElement*>(*i);
- if (formElement->disabled() || formElement->name().isNull())
+ if (formElement->isDisabledFormControl() || formElement->name().isNull())
continue;
FormDataList dataList(*encoding);
+2013-03-28 Matt Falkenhagen <falken@chromium.org>
+
+ Refactoring: Replace Element::disabled and isEnabledFormControl with isDisabledFormControl
+ https://bugs.webkit.org/show_bug.cgi?id=113273
+
+ Reviewed by Kent Tamura.
+
+ Element::disabled is about form controls and Element::isEnabledFormControl
+ is redundant with it, so replace them with a single function
+ Element::isDisabledFormControl.
+
+ * DOMHTMLClasses.cpp:
+ (DOMHTMLInputElement::disabled):
+
2013-03-27 Mark Lam <mark.lam@apple.com>
Rolling out r147044.
{
ASSERT(m_element && m_element->hasTagName(inputTag));
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(m_element);
- *result = inputElement->disabled() ? TRUE : FALSE;
+ *result = inputElement->isDisabledFormControl() ? TRUE : FALSE;
return S_OK;
}