OLD | NEW |
---|---|
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 Loading... | |
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 SparseAttributeMapAdapter : public AXSparseAttributeMap { | |
aboxhall
2017/01/10 05:59:59
WebAX[...]Wrapper/Adapter?
dmazzoni
2017/01/12 03:36:24
This is now SparseAttributeClientAdapter
I'm not
aboxhall
2017/01/12 04:26:51
I meant because it's adapting WebAXSparseAttribute
| |
66 public: | |
67 SparseAttributeMapAdapter(WebAXSparseAttributeMap& attributeMap) | |
68 : m_attributeMap(attributeMap) {} | |
69 virtual ~SparseAttributeMapAdapter() {} | |
70 | |
71 private: | |
72 WebAXSparseAttributeMap& 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 Loading... | |
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(WebAXSparseAttributeMap& sink) const { | |
240 if (isDetached()) | |
241 return; | |
242 | |
243 SparseAttributeMapAdapter adapter(sink); | |
244 m_private->getSparseAXAttributes(adapter); | |
245 } | |
246 | |
203 bool WebAXObject::canSetSelectedAttribute() const { | 247 bool WebAXObject::canSetSelectedAttribute() const { |
204 if (isDetached()) | 248 if (isDetached()) |
205 return false; | 249 return false; |
206 | 250 |
207 return m_private->canSetSelectedAttribute(); | 251 return m_private->canSetSelectedAttribute(); |
208 } | 252 } |
209 | 253 |
210 bool WebAXObject::isAnchor() const { | 254 bool WebAXObject::isAnchor() const { |
211 if (isDetached()) | 255 if (isDetached()) |
212 return false; | 256 return false; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
425 return m_private->colorValue(); | 469 return m_private->colorValue(); |
426 } | 470 } |
427 | 471 |
428 WebAXObject WebAXObject::ariaActiveDescendant() const { | 472 WebAXObject WebAXObject::ariaActiveDescendant() const { |
429 if (isDetached()) | 473 if (isDetached()) |
430 return WebAXObject(); | 474 return WebAXObject(); |
431 | 475 |
432 return WebAXObject(m_private->activeDescendant()); | 476 return WebAXObject(m_private->activeDescendant()); |
433 } | 477 } |
434 | 478 |
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 { | 479 bool WebAXObject::ariaHasPopup() const { |
451 if (isDetached()) | 480 if (isDetached()) |
452 return false; | 481 return false; |
453 | 482 |
454 return m_private->ariaHasPopup(); | 483 return m_private->ariaHasPopup(); |
455 } | 484 } |
456 | 485 |
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 { | 486 bool WebAXObject::isEditable() const { |
473 if (isDetached()) | 487 if (isDetached()) |
474 return false; | 488 return false; |
475 | 489 |
476 return m_private->isEditable(); | 490 return m_private->isEditable(); |
477 } | 491 } |
478 | 492 |
479 bool WebAXObject::isMultiline() const { | 493 bool WebAXObject::isMultiline() const { |
480 if (isDetached()) | 494 if (isDetached()) |
481 return false; | 495 return false; |
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1510 WebAXObject& WebAXObject::operator=(AXObject* object) { | 1524 WebAXObject& WebAXObject::operator=(AXObject* object) { |
1511 m_private = object; | 1525 m_private = object; |
1512 return *this; | 1526 return *this; |
1513 } | 1527 } |
1514 | 1528 |
1515 WebAXObject::operator AXObject*() const { | 1529 WebAXObject::operator AXObject*() const { |
1516 return m_private.get(); | 1530 return m_private.get(); |
1517 } | 1531 } |
1518 | 1532 |
1519 } // namespace blink | 1533 } // namespace blink |
OLD | NEW |