Simplify event handling logic for search cancel button
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2015 17:20:53 +0000 (17:20 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Jun 2015 17:20:53 +0000 (17:20 +0000)
commit1db3be283b140fd759462a9e5ecfb9d7fa4c6ced
tree4f89ae88c0457566336f3c4af3a65f2797e19d8a
parent4924b888f0f6f09a0a13c00115694cc4207aa232
Simplify event handling logic for search cancel button
https://bugs.webkit.org/show_bug.cgi?id=145780

Reviewed by Darin Adler.

Following the patch for <https://bugs.webkit.org/show_bug.cgi?id=145774> we can take advantage
of the DOM click event to simplify the event handling logic for the search cancel button.
It is sufficient to listen for mousedown and click events instead of listening for mousedown
and mouseup events, capturing all events during drag, and using the hover state of the button
on mouse release together with a instance variable set on mouse press to determine whether
the cancel button was clicked.

As a side effect of removing the requirement that the search cancel button be hovered (a
workaround to ensure that the mouse was pressed and released on the button in absence of
listening for an explicit DOM click event) we can remove the accessibility-specific class,
AccessibilitySearchFieldCancelButton, that was primarily used to fake the hover state of
the button so that the accessibility machinery could simulate a click on it. Instead we
can add use the default accessibility machinery for clicking on an element.

No new tests since no functionality was changed.

* CMakeLists.txt: Remove reference to file AccessibilitySearchFieldButtons.cpp.
* WebCore.vcxproj/WebCore.vcxproj: Remove reference to files AccessibilitySearchFieldButtons.{cpp, h}.
* WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* accessibility/AXObjectCache.cpp:
(WebCore::createFromRenderer): Remove special-purpose logic that instantiated
AccessibilitySearchFieldCancelButton for the search cancel button. Instead we can make
use of the existing accessibility machinery to handle this button.
* accessibility/AccessibilityAllInOne.cpp: Remove #include of AccessibilitySearchFieldButtons.cpp
since the file is no longer needed.
* accessibility/AccessibilitySearchFieldButtons.cpp: Removed.
* accessibility/AccessibilitySearchFieldButtons.h: Removed.
* dom/Element.h:
(WebCore::Element::isSearchFieldCancelButtonElement): Deleted.
* html/shadow/TextControlInnerElements.cpp:
(WebCore::SearchFieldCancelButtonElement::SearchFieldCancelButtonElement): Set the ARIA role
and label attributes so that the accessibility system identifies the search cancel button as
a button and shows a description for the button, respectively.
(WebCore::SearchFieldCancelButtonElement::defaultEventHandler): Simplify the event handling logic
such that we clear the field when we receive a DOM click event (i.e. the mouse was pressed
and released on the button). Remove unused variable, oldValue. Substitute emptyString() for the
empty string literal in the call to HTMLInputElement::setValueForUser() to avoid an implicit
conversion to String. Also remove out-of-date comment that repeated what the code does.
(WebCore::SearchFieldCancelButtonElement::willDetachRenderers): Deleted. We no longer need to use
custom style resolve callbacks to reset the state of the EventHandler since we no longer need to
have the EventHandler dispatch all mouse events to us on mouse press.
* html/shadow/TextControlInnerElements.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/accessibility/AXObjectCache.cpp
Source/WebCore/accessibility/AccessibilityAllInOne.cpp
Source/WebCore/accessibility/AccessibilitySearchFieldButtons.cpp [deleted file]
Source/WebCore/accessibility/AccessibilitySearchFieldButtons.h [deleted file]
Source/WebCore/dom/Element.h
Source/WebCore/html/shadow/TextControlInnerElements.cpp
Source/WebCore/html/shadow/TextControlInnerElements.h