Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1145)

Unified Diff: Source/core/html/shadow/PickerIndicatorElement.cpp

Issue 577553002: AX: Make picker indicator elements focusable if accessibility is enabled. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/shadow/PickerIndicatorElement.h ('k') | public/platform/WebLocalizedString.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/shadow/PickerIndicatorElement.cpp
diff --git a/Source/core/html/shadow/PickerIndicatorElement.cpp b/Source/core/html/shadow/PickerIndicatorElement.cpp
index 17115a47ea6152a2fa426085993a61f91d619ff6..342a19ecfca2822ff74cb625cb0c1f6f91031304 100644
--- a/Source/core/html/shadow/PickerIndicatorElement.cpp
+++ b/Source/core/html/shadow/PickerIndicatorElement.cpp
@@ -33,10 +33,15 @@
#include "core/html/shadow/PickerIndicatorElement.h"
#include "core/events/Event.h"
+#include "core/events/KeyboardEvent.h"
+#include "core/frame/Settings.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/page/Chrome.h"
#include "core/page/Page.h"
#include "core/rendering/RenderDetailsMarker.h"
+#include "platform/LayoutTestSupport.h"
+#include "platform/text/PlatformLocale.h"
+#include "public/platform/WebLocalizedString.h"
#include "wtf/TemporaryChange.h"
using namespace WTF::Unicode;
@@ -81,6 +86,12 @@ void PickerIndicatorElement::defaultEventHandler(Event* event)
if (event->type() == EventTypeNames::click) {
openPopup();
event->setDefaultHandled();
+ } else if (event->type() == EventTypeNames::keypress && event->isKeyboardEvent()) {
+ int charCode = toKeyboardEvent(event)->charCode();
+ if (charCode == ' ' || charCode == '\r') {
+ openPopup();
+ event->setDefaultHandled();
+ }
}
if (!event->defaultHandled())
@@ -162,6 +173,26 @@ bool PickerIndicatorElement::isPickerIndicatorElement() const
return true;
}
+Node::InsertionNotificationRequest PickerIndicatorElement::insertedInto(ContainerNode* insertionPoint)
+{
+ HTMLDivElement::insertedInto(insertionPoint);
+ return InsertionShouldCallDidNotifySubtreeInsertions;
+}
+
+void PickerIndicatorElement::didNotifySubtreeInsertionsToDocument()
+{
+ if (!document().settings() || !document().settings()->accessibilityEnabled())
+ return;
+ // Don't make this focusable if we are in layout tests in order to avoid to
+ // break existing tests.
+ // FIXME: We should have a way to disable accessibility in layout tests.
+ if (LayoutTestSupport::isRunningLayoutTest())
+ return;
+ setAttribute(tabindexAttr, "0");
+ setAttribute(aria_labelAttr, AtomicString(locale().queryString(WebLocalizedString::AXShowPickerButton)));
+ setAttribute(roleAttr, "button");
+}
+
void PickerIndicatorElement::trace(Visitor* visitor)
{
visitor->trace(m_pickerIndicatorOwner);
« no previous file with comments | « Source/core/html/shadow/PickerIndicatorElement.h ('k') | public/platform/WebLocalizedString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698