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

Side by Side Diff: Source/modules/accessibility/AXMediaControls.cpp

Issue 742353004: Implement computedRole and computedName (behind a flag) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Finished pulling out ScopedAXObjectCache etc. Many fprintfs remain. Created 6 years 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 12 matching lines...) Expand all
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29 29
30 #include "config.h" 30 #include "config.h"
31 #include "modules/accessibility/AXMediaControls.h" 31 #include "modules/accessibility/AXMediaControls.h"
32 32
33 #include "core/dom/AXObjectCache.h"
33 #include "platform/text/PlatformLocale.h" 34 #include "platform/text/PlatformLocale.h"
34 35
35 namespace blink { 36 namespace blink {
36 37
37 using blink::WebLocalizedString; 38 using blink::WebLocalizedString;
38 using namespace HTMLNames; 39 using namespace HTMLNames;
39 40
40 static inline String queryString(WebLocalizedString::Name name) 41 static inline String queryString(WebLocalizedString::Name name)
41 { 42 {
42 return Locale::defaultLocale().queryString(name); 43 return Locale::defaultLocale().queryString(name);
43 } 44 }
44 45
45 AccessibilityMediaControl::AccessibilityMediaControl(RenderObject* renderer) 46 AccessibilityMediaControl::AccessibilityMediaControl(RenderObject* renderer, AXO bjectCache* axObjectCache)
46 : AXRenderObject(renderer) 47 : AXRenderObject(renderer, axObjectCache)
47 { 48 {
48 } 49 }
49 50
50 PassRefPtr<AXObject> AccessibilityMediaControl::create(RenderObject* renderer) 51 PassRefPtr<AXObject> AccessibilityMediaControl::create(RenderObject* renderer, A XObjectCache* axObjectCache)
51 { 52 {
52 ASSERT(renderer->node()); 53 ASSERT(renderer->node());
53 54
54 switch (mediaControlElementType(renderer->node())) { 55 switch (mediaControlElementType(renderer->node())) {
55 case MediaSlider: 56 case MediaSlider:
56 return AccessibilityMediaTimeline::create(renderer); 57 return AccessibilityMediaTimeline::create(renderer, axObjectCache);
57 58
58 case MediaCurrentTimeDisplay: 59 case MediaCurrentTimeDisplay:
59 case MediaTimeRemainingDisplay: 60 case MediaTimeRemainingDisplay:
60 return AccessibilityMediaTimeDisplay::create(renderer); 61 return AccessibilityMediaTimeDisplay::create(renderer, axObjectCache);
61 62
62 case MediaControlsPanel: 63 case MediaControlsPanel:
63 return AXMediaControlsContainer::create(renderer); 64 return AXMediaControlsContainer::create(renderer, axObjectCache);
64 65
65 default: 66 default:
66 return adoptRef(new AccessibilityMediaControl(renderer)); 67 return adoptRef(new AccessibilityMediaControl(renderer, axObjectCache));
67 } 68 }
68 } 69 }
69 70
70 MediaControlElementType AccessibilityMediaControl::controlType() const 71 MediaControlElementType AccessibilityMediaControl::controlType() const
71 { 72 {
72 if (!renderer() || !renderer()->node()) 73 if (!renderer() || !renderer()->node())
73 return MediaTimelineContainer; // Timeline container is not accessible. 74 return MediaTimelineContainer; // Timeline container is not accessible.
74 75
75 return mediaControlElementType(renderer()->node()); 76 return mediaControlElementType(renderer()->node());
76 } 77 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 186 }
186 187
187 return UnknownRole; 188 return UnknownRole;
188 } 189 }
189 190
190 191
191 192
192 // 193 //
193 // AXMediaControlsContainer 194 // AXMediaControlsContainer
194 195
195 AXMediaControlsContainer::AXMediaControlsContainer(RenderObject* renderer) 196 AXMediaControlsContainer::AXMediaControlsContainer(RenderObject* renderer, AXObj ectCache* axObjectCache)
196 : AccessibilityMediaControl(renderer) 197 : AccessibilityMediaControl(renderer, axObjectCache)
197 { 198 {
198 } 199 }
199 200
200 PassRefPtr<AXObject> AXMediaControlsContainer::create(RenderObject* renderer) 201 PassRefPtr<AXObject> AXMediaControlsContainer::create(RenderObject* renderer, AX ObjectCache* axObjectCache)
201 { 202 {
202 return adoptRef(new AXMediaControlsContainer(renderer)); 203 return adoptRef(new AXMediaControlsContainer(renderer, axObjectCache));
203 } 204 }
204 205
205 String AXMediaControlsContainer::accessibilityDescription() const 206 String AXMediaControlsContainer::accessibilityDescription() const
206 { 207 {
207 return queryString(isControllingVideoElement() ? WebLocalizedString::AXMedia VideoElement : WebLocalizedString::AXMediaAudioElement); 208 return queryString(isControllingVideoElement() ? WebLocalizedString::AXMedia VideoElement : WebLocalizedString::AXMediaAudioElement);
208 } 209 }
209 210
210 String AXMediaControlsContainer::helpText() const 211 String AXMediaControlsContainer::helpText() const
211 { 212 {
212 return queryString(isControllingVideoElement() ? WebLocalizedString::AXMedia VideoElementHelp : WebLocalizedString::AXMediaAudioElementHelp); 213 return queryString(isControllingVideoElement() ? WebLocalizedString::AXMedia VideoElementHelp : WebLocalizedString::AXMediaAudioElementHelp);
213 } 214 }
214 215
215 bool AXMediaControlsContainer::computeAccessibilityIsIgnored() const 216 bool AXMediaControlsContainer::computeAccessibilityIsIgnored() const
216 { 217 {
217 return accessibilityIsIgnoredByDefault(); 218 return accessibilityIsIgnoredByDefault();
218 } 219 }
219 220
220 // 221 //
221 // AccessibilityMediaTimeline 222 // AccessibilityMediaTimeline
222 223
223 static String localizedMediaTimeDescription(float /*time*/) 224 static String localizedMediaTimeDescription(float /*time*/)
224 { 225 {
225 // FIXME: To be fixed. See 226 // FIXME: To be fixed. See
226 // http://trac.webkit.org/browser/trunk/Source/WebCore/platform/LocalizedStr ings.cpp#L928 227 // http://trac.webkit.org/browser/trunk/Source/WebCore/platform/LocalizedStr ings.cpp#L928
227 return String(); 228 return String();
228 } 229 }
229 230
230 AccessibilityMediaTimeline::AccessibilityMediaTimeline(RenderObject* renderer) 231 AccessibilityMediaTimeline::AccessibilityMediaTimeline(RenderObject* renderer, A XObjectCache* axObjectCache)
231 : AXSlider(renderer) 232 : AXSlider(renderer, axObjectCache)
232 { 233 {
233 } 234 }
234 235
235 PassRefPtr<AXObject> AccessibilityMediaTimeline::create(RenderObject* renderer) 236 PassRefPtr<AXObject> AccessibilityMediaTimeline::create(RenderObject* renderer, AXObjectCache* axObjectCache)
236 { 237 {
237 return adoptRef(new AccessibilityMediaTimeline(renderer)); 238 return adoptRef(new AccessibilityMediaTimeline(renderer, axObjectCache));
238 } 239 }
239 240
240 String AccessibilityMediaTimeline::valueDescription() const 241 String AccessibilityMediaTimeline::valueDescription() const
241 { 242 {
242 Node* node = m_renderer->node(); 243 Node* node = m_renderer->node();
243 if (!isHTMLInputElement(node)) 244 if (!isHTMLInputElement(node))
244 return String(); 245 return String();
245 246
246 return localizedMediaTimeDescription(toHTMLInputElement(node)->value().toFlo at()); 247 return localizedMediaTimeDescription(toHTMLInputElement(node)->value().toFlo at());
247 } 248 }
248 249
249 String AccessibilityMediaTimeline::helpText() const 250 String AccessibilityMediaTimeline::helpText() const
250 { 251 {
251 return queryString(isControllingVideoElement() ? WebLocalizedString::AXMedia VideoSliderHelp : WebLocalizedString::AXMediaAudioSliderHelp); 252 return queryString(isControllingVideoElement() ? WebLocalizedString::AXMedia VideoSliderHelp : WebLocalizedString::AXMediaAudioSliderHelp);
252 } 253 }
253 254
254 255
255 // 256 //
256 // AccessibilityMediaTimeDisplay 257 // AccessibilityMediaTimeDisplay
257 258
258 AccessibilityMediaTimeDisplay::AccessibilityMediaTimeDisplay(RenderObject* rende rer) 259 AccessibilityMediaTimeDisplay::AccessibilityMediaTimeDisplay(RenderObject* rende rer, AXObjectCache* axObjectCache)
259 : AccessibilityMediaControl(renderer) 260 : AccessibilityMediaControl(renderer, axObjectCache)
260 { 261 {
261 } 262 }
262 263
263 PassRefPtr<AXObject> AccessibilityMediaTimeDisplay::create(RenderObject* rendere r) 264 PassRefPtr<AXObject> AccessibilityMediaTimeDisplay::create(RenderObject* rendere r, AXObjectCache* axObjectCache)
264 { 265 {
265 return adoptRef(new AccessibilityMediaTimeDisplay(renderer)); 266 return adoptRef(new AccessibilityMediaTimeDisplay(renderer, axObjectCache));
266 } 267 }
267 268
268 bool AccessibilityMediaTimeDisplay::computeAccessibilityIsIgnored() const 269 bool AccessibilityMediaTimeDisplay::computeAccessibilityIsIgnored() const
269 { 270 {
270 if (!m_renderer || !m_renderer->style() || m_renderer->style()->visibility() != VISIBLE) 271 if (!m_renderer || !m_renderer->style() || m_renderer->style()->visibility() != VISIBLE)
271 return true; 272 return true;
272 273
273 if (!m_renderer->style()->width().value()) 274 if (!m_renderer->style()->width().value())
274 return true; 275 return true;
275 276
(...skipping 11 matching lines...) Expand all
287 { 288 {
288 if (!m_renderer || !m_renderer->node()) 289 if (!m_renderer || !m_renderer->node())
289 return String(); 290 return String();
290 291
291 MediaControlTimeDisplayElement* element = static_cast<MediaControlTimeDispla yElement*>(m_renderer->node()); 292 MediaControlTimeDisplayElement* element = static_cast<MediaControlTimeDispla yElement*>(m_renderer->node());
292 float time = element->currentValue(); 293 float time = element->currentValue();
293 return localizedMediaTimeDescription(fabsf(time)); 294 return localizedMediaTimeDescription(fabsf(time));
294 } 295 }
295 296
296 } // namespace blink 297 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698