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

Side by Side Diff: third_party/WebKit/Source/web/WebAXObject.cpp

Issue 2589273002: Add sparse accessibility attribute interface to Blink (Closed)
Patch Set: Address feedback Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #include "public/platform/WebURL.h" 55 #include "public/platform/WebURL.h"
56 #include "public/web/WebDocument.h" 56 #include "public/web/WebDocument.h"
57 #include "public/web/WebElement.h" 57 #include "public/web/WebElement.h"
58 #include "public/web/WebNode.h" 58 #include "public/web/WebNode.h"
59 #include "web/WebLocalFrameImpl.h" 59 #include "web/WebLocalFrameImpl.h"
60 #include "web/WebViewImpl.h" 60 #include "web/WebViewImpl.h"
61 #include "wtf/text/StringBuilder.h" 61 #include "wtf/text/StringBuilder.h"
62 62
63 namespace blink { 63 namespace blink {
64 64
65 class WebAXSparseAttributeClientAdapter : public AXSparseAttributeClient {
66 public:
67 WebAXSparseAttributeClientAdapter(WebAXSparseAttributeClient& attributeMap)
68 : m_attributeMap(attributeMap) {}
69 virtual ~WebAXSparseAttributeClientAdapter() {}
70
71 private:
72 WebAXSparseAttributeClient& m_attributeMap;
73
74 void addBoolAttribute(AXBoolAttribute attribute, bool value) override {
75 m_attributeMap.addBoolAttribute(static_cast<WebAXBoolAttribute>(attribute),
76 value);
77 }
78
79 void addStringAttribute(AXStringAttribute attribute,
80 const String& value) override {
81 m_attributeMap.addStringAttribute(
82 static_cast<WebAXStringAttribute>(attribute), value);
83 }
84
85 void addObjectAttribute(AXObjectAttribute attribute,
86 AXObject& value) override {
87 m_attributeMap.addObjectAttribute(
88 static_cast<WebAXObjectAttribute>(attribute), WebAXObject(&value));
89 }
90
91 void addObjectVectorAttribute(AXObjectVectorAttribute attribute,
92 HeapVector<Member<AXObject>>& value) override {
93 WebVector<WebAXObject> result(value.size());
94 for (size_t i = 0; i < value.size(); i++)
95 result[i] = WebAXObject(value[i]);
96 m_attributeMap.addObjectVectorAttribute(
97 static_cast<WebAXObjectVectorAttribute>(attribute), result);
98 }
99 };
100
65 #if DCHECK_IS_ON() 101 #if DCHECK_IS_ON()
66 // It's not safe to call some WebAXObject APIs if a layout is pending. 102 // It's not safe to call some WebAXObject APIs if a layout is pending.
67 // Clients should call updateLayoutAndCheckValidity first. 103 // Clients should call updateLayoutAndCheckValidity first.
68 static bool isLayoutClean(Document* document) { 104 static bool isLayoutClean(Document* document) {
69 if (!document || !document->view()) 105 if (!document || !document->view())
70 return false; 106 return false;
71 return document->lifecycle().state() >= DocumentLifecycle::LayoutClean || 107 return document->lifecycle().state() >= DocumentLifecycle::LayoutClean ||
72 ((document->lifecycle().state() == DocumentLifecycle::StyleClean || 108 ((document->lifecycle().state() == DocumentLifecycle::StyleClean ||
73 document->lifecycle().state() == 109 document->lifecycle().state() ==
74 DocumentLifecycle::LayoutSubtreeChangeClean) && 110 DocumentLifecycle::LayoutSubtreeChangeClean) &&
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return WebAXObject(m_private->children()[index]); 229 return WebAXObject(m_private->children()[index]);
194 } 230 }
195 231
196 WebAXObject WebAXObject::parentObject() const { 232 WebAXObject WebAXObject::parentObject() const {
197 if (isDetached()) 233 if (isDetached())
198 return WebAXObject(); 234 return WebAXObject();
199 235
200 return WebAXObject(m_private->parentObject()); 236 return WebAXObject(m_private->parentObject());
201 } 237 }
202 238
239 void WebAXObject::getSparseAXAttributes(
240 WebAXSparseAttributeClient& client) const {
241 if (isDetached())
242 return;
243
244 WebAXSparseAttributeClientAdapter adapter(client);
245 m_private->getSparseAXAttributes(adapter);
246 }
247
203 bool WebAXObject::canSetSelectedAttribute() const { 248 bool WebAXObject::canSetSelectedAttribute() const {
204 if (isDetached()) 249 if (isDetached())
205 return false; 250 return false;
206 251
207 return m_private->canSetSelectedAttribute(); 252 return m_private->canSetSelectedAttribute();
208 } 253 }
209 254
210 bool WebAXObject::isAnchor() const { 255 bool WebAXObject::isAnchor() const {
211 if (isDetached()) 256 if (isDetached())
212 return false; 257 return false;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 return m_private->colorValue(); 470 return m_private->colorValue();
426 } 471 }
427 472
428 WebAXObject WebAXObject::ariaActiveDescendant() const { 473 WebAXObject WebAXObject::ariaActiveDescendant() const {
429 if (isDetached()) 474 if (isDetached())
430 return WebAXObject(); 475 return WebAXObject();
431 476
432 return WebAXObject(m_private->activeDescendant()); 477 return WebAXObject(m_private->activeDescendant());
433 } 478 }
434 479
435 bool WebAXObject::ariaControls(WebVector<WebAXObject>& controlsElements) const {
436 if (isDetached())
437 return false;
438
439 AXObject::AXObjectVector controls;
440 m_private->ariaControlsElements(controls);
441
442 WebVector<WebAXObject> result(controls.size());
443 for (size_t i = 0; i < controls.size(); i++)
444 result[i] = WebAXObject(controls[i]);
445 controlsElements.swap(result);
446
447 return true;
448 }
449
450 bool WebAXObject::ariaHasPopup() const { 480 bool WebAXObject::ariaHasPopup() const {
451 if (isDetached()) 481 if (isDetached())
452 return false; 482 return false;
453 483
454 return m_private->ariaHasPopup(); 484 return m_private->ariaHasPopup();
455 } 485 }
456 486
457 bool WebAXObject::ariaFlowTo(WebVector<WebAXObject>& flowToElements) const {
458 if (isDetached())
459 return false;
460
461 AXObject::AXObjectVector flowTo;
462 m_private->ariaFlowToElements(flowTo);
463
464 WebVector<WebAXObject> result(flowTo.size());
465 for (size_t i = 0; i < flowTo.size(); i++)
466 result[i] = WebAXObject(flowTo[i]);
467 flowToElements.swap(result);
468
469 return true;
470 }
471
472 bool WebAXObject::isEditable() const { 487 bool WebAXObject::isEditable() const {
473 if (isDetached()) 488 if (isDetached())
474 return false; 489 return false;
475 490
476 return m_private->isEditable(); 491 return m_private->isEditable();
477 } 492 }
478 493
479 bool WebAXObject::isMultiline() const { 494 bool WebAXObject::isMultiline() const {
480 if (isDetached()) 495 if (isDetached())
481 return false; 496 return false;
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 WebAXObject& WebAXObject::operator=(AXObject* object) { 1525 WebAXObject& WebAXObject::operator=(AXObject* object) {
1511 m_private = object; 1526 m_private = object;
1512 return *this; 1527 return *this;
1513 } 1528 }
1514 1529
1515 WebAXObject::operator AXObject*() const { 1530 WebAXObject::operator AXObject*() const {
1516 return m_private.get(); 1531 return m_private.get();
1517 } 1532 }
1518 1533
1519 } // namespace blink 1534 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/AssertMatchingEnums.cpp ('k') | third_party/WebKit/public/web/WebAXEnums.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698