OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) | 32 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) |
33 #include "core/html/shadow/PickerIndicatorElement.h" | 33 #include "core/html/shadow/PickerIndicatorElement.h" |
34 | 34 |
35 #include "core/events/Event.h" | 35 #include "core/events/Event.h" |
| 36 #include "core/events/KeyboardEvent.h" |
| 37 #include "core/frame/Settings.h" |
36 #include "core/html/shadow/ShadowElementNames.h" | 38 #include "core/html/shadow/ShadowElementNames.h" |
37 #include "core/page/Chrome.h" | 39 #include "core/page/Chrome.h" |
38 #include "core/page/Page.h" | 40 #include "core/page/Page.h" |
39 #include "core/rendering/RenderDetailsMarker.h" | 41 #include "core/rendering/RenderDetailsMarker.h" |
| 42 #include "platform/LayoutTestSupport.h" |
| 43 #include "platform/text/PlatformLocale.h" |
| 44 #include "public/platform/WebLocalizedString.h" |
40 #include "wtf/TemporaryChange.h" | 45 #include "wtf/TemporaryChange.h" |
41 | 46 |
42 using namespace WTF::Unicode; | 47 using namespace WTF::Unicode; |
43 | 48 |
44 namespace blink { | 49 namespace blink { |
45 | 50 |
46 using namespace HTMLNames; | 51 using namespace HTMLNames; |
47 | 52 |
48 inline PickerIndicatorElement::PickerIndicatorElement(Document& document, Picker
IndicatorOwner& pickerIndicatorOwner) | 53 inline PickerIndicatorElement::PickerIndicatorElement(Document& document, Picker
IndicatorOwner& pickerIndicatorOwner) |
49 : HTMLDivElement(document) | 54 : HTMLDivElement(document) |
(...skipping 24 matching lines...) Expand all Loading... |
74 void PickerIndicatorElement::defaultEventHandler(Event* event) | 79 void PickerIndicatorElement::defaultEventHandler(Event* event) |
75 { | 80 { |
76 if (!renderer()) | 81 if (!renderer()) |
77 return; | 82 return; |
78 if (!m_pickerIndicatorOwner || m_pickerIndicatorOwner->isPickerIndicatorOwne
rDisabledOrReadOnly()) | 83 if (!m_pickerIndicatorOwner || m_pickerIndicatorOwner->isPickerIndicatorOwne
rDisabledOrReadOnly()) |
79 return; | 84 return; |
80 | 85 |
81 if (event->type() == EventTypeNames::click) { | 86 if (event->type() == EventTypeNames::click) { |
82 openPopup(); | 87 openPopup(); |
83 event->setDefaultHandled(); | 88 event->setDefaultHandled(); |
| 89 } else if (event->type() == EventTypeNames::keypress && event->isKeyboardEve
nt()) { |
| 90 int charCode = toKeyboardEvent(event)->charCode(); |
| 91 if (charCode == ' ' || charCode == '\r') { |
| 92 openPopup(); |
| 93 event->setDefaultHandled(); |
| 94 } |
84 } | 95 } |
85 | 96 |
86 if (!event->defaultHandled()) | 97 if (!event->defaultHandled()) |
87 HTMLDivElement::defaultEventHandler(event); | 98 HTMLDivElement::defaultEventHandler(event); |
88 } | 99 } |
89 | 100 |
90 bool PickerIndicatorElement::willRespondToMouseClickEvents() | 101 bool PickerIndicatorElement::willRespondToMouseClickEvents() |
91 { | 102 { |
92 if (renderer() && m_pickerIndicatorOwner && !m_pickerIndicatorOwner->isPicke
rIndicatorOwnerDisabledOrReadOnly()) | 103 if (renderer() && m_pickerIndicatorOwner && !m_pickerIndicatorOwner->isPicke
rIndicatorOwnerDisabledOrReadOnly()) |
93 return true; | 104 return true; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 AXObject* PickerIndicatorElement::popupRootAXObject() const | 166 AXObject* PickerIndicatorElement::popupRootAXObject() const |
156 { | 167 { |
157 return m_chooser ? m_chooser->rootAXObject() : 0; | 168 return m_chooser ? m_chooser->rootAXObject() : 0; |
158 } | 169 } |
159 | 170 |
160 bool PickerIndicatorElement::isPickerIndicatorElement() const | 171 bool PickerIndicatorElement::isPickerIndicatorElement() const |
161 { | 172 { |
162 return true; | 173 return true; |
163 } | 174 } |
164 | 175 |
| 176 Node::InsertionNotificationRequest PickerIndicatorElement::insertedInto(Containe
rNode* insertionPoint) |
| 177 { |
| 178 HTMLDivElement::insertedInto(insertionPoint); |
| 179 return InsertionShouldCallDidNotifySubtreeInsertions; |
| 180 } |
| 181 |
| 182 void PickerIndicatorElement::didNotifySubtreeInsertionsToDocument() |
| 183 { |
| 184 if (!document().settings() || !document().settings()->accessibilityEnabled()
) |
| 185 return; |
| 186 // Don't make this focusable if we are in layout tests in order to avoid to |
| 187 // break existing tests. |
| 188 // FIXME: We should have a way to disable accessibility in layout tests. |
| 189 if (LayoutTestSupport::isRunningLayoutTest()) |
| 190 return; |
| 191 setAttribute(tabindexAttr, "0"); |
| 192 setAttribute(aria_labelAttr, AtomicString(locale().queryString(WebLocalizedS
tring::AXShowPickerButton))); |
| 193 setAttribute(roleAttr, "button"); |
| 194 } |
| 195 |
165 void PickerIndicatorElement::trace(Visitor* visitor) | 196 void PickerIndicatorElement::trace(Visitor* visitor) |
166 { | 197 { |
167 visitor->trace(m_pickerIndicatorOwner); | 198 visitor->trace(m_pickerIndicatorOwner); |
168 HTMLDivElement::trace(visitor); | 199 HTMLDivElement::trace(visitor); |
169 } | 200 } |
170 | 201 |
171 } | 202 } |
172 | 203 |
173 #endif | 204 #endif |
OLD | NEW |