|
Lines 37-45
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec1
|
| 37 |
|
37 |
|
| 38 |
namespace WebCore { |
38 |
namespace WebCore { |
| 39 |
|
39 |
|
| 40 |
Ref<AccessibilityObjectAtspi> AccessibilityObjectAtspi::create(AXCoreObject* coreObject) |
40 |
Ref<AccessibilityObjectAtspi> AccessibilityObjectAtspi::create(AXCoreObject* coreObject, AccessibilityRootAtspi& root) |
| 41 |
{ |
41 |
{ |
| 42 |
return adoptRef(*new AccessibilityObjectAtspi(coreObject)); |
42 |
return adoptRef(*new AccessibilityObjectAtspi(coreObject, root)); |
| 43 |
} |
43 |
} |
| 44 |
|
44 |
|
| 45 |
static inline bool roleIsTextType(AccessibilityRole role) |
45 |
static inline bool roleIsTextType(AccessibilityRole role) |
|
Lines 112-120
OptionSet<AccessibilityObjectAtspi::Interface> AccessibilityObjectAtspi::interfa
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec2
|
| 112 |
return interfaces; |
112 |
return interfaces; |
| 113 |
} |
113 |
} |
| 114 |
|
114 |
|
| 115 |
AccessibilityObjectAtspi::AccessibilityObjectAtspi(AXCoreObject* coreObject) |
115 |
AccessibilityObjectAtspi::AccessibilityObjectAtspi(AXCoreObject* coreObject, AccessibilityRootAtspi& root) |
| 116 |
: m_coreObject(coreObject) |
116 |
: m_coreObject(coreObject) |
| 117 |
, m_interfaces(interfacesForObject(*m_coreObject)) |
117 |
, m_interfaces(interfacesForObject(*m_coreObject)) |
|
|
118 |
, m_root(root) |
| 118 |
{ |
119 |
{ |
| 119 |
RELEASE_ASSERT(isMainThread()); |
120 |
RELEASE_ASSERT(isMainThread()); |
| 120 |
} |
121 |
} |
|
Lines 137-143
void AccessibilityObjectAtspi::cacheDestroyed()
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec3
|
| 137 |
if (!m_isRegistered.load()) |
138 |
if (!m_isRegistered.load()) |
| 138 |
return; |
139 |
return; |
| 139 |
|
140 |
|
| 140 |
root()->atspi().unregisterObject(*this); |
141 |
m_root.atspi().unregisterObject(*this); |
| 141 |
} |
142 |
} |
| 142 |
|
143 |
|
| 143 |
void AccessibilityObjectAtspi::elementDestroyed() |
144 |
void AccessibilityObjectAtspi::elementDestroyed() |
|
Lines 150-156
void AccessibilityObjectAtspi::elementDestroyed()
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec4
|
| 150 |
if (m_parent && *m_parent) |
151 |
if (m_parent && *m_parent) |
| 151 |
m_parent.value()->childRemoved(*this); |
152 |
m_parent.value()->childRemoved(*this); |
| 152 |
|
153 |
|
| 153 |
root()->atspi().unregisterObject(*this); |
154 |
m_root.atspi().unregisterObject(*this); |
| 154 |
} |
155 |
} |
| 155 |
|
156 |
|
| 156 |
static unsigned atspiRole(AccessibilityRole role) |
157 |
static unsigned atspiRole(AccessibilityRole role) |
|
Lines 429-440
GDBusInterfaceVTable AccessibilityObjectAtspi::s_accessibleFunctions = {
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec5
|
| 429 |
|
430 |
|
| 430 |
g_dbus_method_invocation_return_value(invocation, g_variant_builder_end(&builder)); |
431 |
g_dbus_method_invocation_return_value(invocation, g_variant_builder_end(&builder)); |
| 431 |
} else if (!g_strcmp0(methodName, "GetApplication")) |
432 |
} else if (!g_strcmp0(methodName, "GetApplication")) |
| 432 |
g_dbus_method_invocation_return_value(invocation, g_variant_new("(@(so))", atspiObject->root()->applicationReference())); |
433 |
g_dbus_method_invocation_return_value(invocation, g_variant_new("(@(so))", atspiObject->m_root.applicationReference())); |
| 433 |
else if (!g_strcmp0(methodName, "GetChildAtIndex")) { |
434 |
else if (!g_strcmp0(methodName, "GetChildAtIndex")) { |
| 434 |
int index; |
435 |
int index; |
| 435 |
g_variant_get(parameters, "(i)", &index); |
436 |
g_variant_get(parameters, "(i)", &index); |
| 436 |
auto* wrapper = index >= 0 ? atspiObject->childAt(index) : nullptr; |
437 |
auto* wrapper = index >= 0 ? atspiObject->childAt(index) : nullptr; |
| 437 |
g_dbus_method_invocation_return_value(invocation, g_variant_new("(@(so))", wrapper ? wrapper->reference() : atspiObject->root()->atspi().nullReference())); |
438 |
g_dbus_method_invocation_return_value(invocation, g_variant_new("(@(so))", wrapper ? wrapper->reference() : atspiObject->m_root.atspi().nullReference())); |
| 438 |
} else if (!g_strcmp0(methodName, "GetChildren")) { |
439 |
} else if (!g_strcmp0(methodName, "GetChildren")) { |
| 439 |
GVariantBuilder builder = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE("a(so)")); |
440 |
GVariantBuilder builder = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE("a(so)")); |
| 440 |
for (const auto& wrapper : atspiObject->children()) |
441 |
for (const auto& wrapper : atspiObject->children()) |
|
Lines 484-491
const String& AccessibilityObjectAtspi::path()
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec6
|
| 484 |
{ |
485 |
{ |
| 485 |
RELEASE_ASSERT(!isMainThread()); |
486 |
RELEASE_ASSERT(!isMainThread()); |
| 486 |
if (m_path.isNull()) { |
487 |
if (m_path.isNull()) { |
| 487 |
auto* atspiRoot = root(); |
|
|
| 488 |
RELEASE_ASSERT(atspiRoot); |
| 489 |
m_isRegistered.store(true); |
488 |
m_isRegistered.store(true); |
| 490 |
|
489 |
|
| 491 |
Vector<std::pair<GDBusInterfaceInfo*, GDBusInterfaceVTable*>> interfaces; |
490 |
Vector<std::pair<GDBusInterfaceInfo*, GDBusInterfaceVTable*>> interfaces; |
|
Lines 513-519
const String& AccessibilityObjectAtspi::path()
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec7
|
| 513 |
interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_table_interface), &s_tableFunctions }); |
512 |
interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_table_interface), &s_tableFunctions }); |
| 514 |
if (m_interfaces.contains(Interface::TableCell)) |
513 |
if (m_interfaces.contains(Interface::TableCell)) |
| 515 |
interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_table_cell_interface), &s_tableCellFunctions }); |
514 |
interfaces.append({ const_cast<GDBusInterfaceInfo*>(&webkit_table_cell_interface), &s_tableCellFunctions }); |
| 516 |
m_path = atspiRoot->atspi().registerObject(*this, WTFMove(interfaces)); |
515 |
m_path = m_root.atspi().registerObject(*this, WTFMove(interfaces)); |
| 517 |
} |
516 |
} |
| 518 |
|
517 |
|
| 519 |
return m_path; |
518 |
return m_path; |
|
Lines 522-528
const String& AccessibilityObjectAtspi::path()
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec8
|
| 522 |
GVariant* AccessibilityObjectAtspi::reference() |
521 |
GVariant* AccessibilityObjectAtspi::reference() |
| 523 |
{ |
522 |
{ |
| 524 |
RELEASE_ASSERT(!isMainThread()); |
523 |
RELEASE_ASSERT(!isMainThread()); |
| 525 |
return g_variant_new("(so)", root()->atspi().uniqueName(), path().utf8().data()); |
524 |
return g_variant_new("(so)", m_root.atspi().uniqueName(), path().utf8().data()); |
| 526 |
} |
525 |
} |
| 527 |
|
526 |
|
| 528 |
GVariant* AccessibilityObjectAtspi::hyperlinkReference() |
527 |
GVariant* AccessibilityObjectAtspi::hyperlinkReference() |
|
Lines 530-551
GVariant* AccessibilityObjectAtspi::hyperlinkReference()
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec9
|
| 530 |
RELEASE_ASSERT(!isMainThread()); |
529 |
RELEASE_ASSERT(!isMainThread()); |
| 531 |
if (m_hyperlinkPath.isNull()) { |
530 |
if (m_hyperlinkPath.isNull()) { |
| 532 |
path(); |
531 |
path(); |
| 533 |
m_hyperlinkPath = root()->atspi().registerHyperlink(*this, { { const_cast<GDBusInterfaceInfo*>(&webkit_hyperlink_interface), &s_hyperlinkFunctions } }); |
532 |
m_hyperlinkPath = m_root.atspi().registerHyperlink(*this, { { const_cast<GDBusInterfaceInfo*>(&webkit_hyperlink_interface), &s_hyperlinkFunctions } }); |
| 534 |
} |
533 |
} |
| 535 |
|
534 |
|
| 536 |
return g_variant_new("(so)", root()->atspi().uniqueName(), m_hyperlinkPath.utf8().data()); |
535 |
return g_variant_new("(so)", m_root.atspi().uniqueName(), m_hyperlinkPath.utf8().data()); |
| 537 |
} |
|
|
| 538 |
|
| 539 |
void AccessibilityObjectAtspi::setRoot(AccessibilityRootAtspi* root) |
| 540 |
{ |
| 541 |
Locker locker { m_rootLock }; |
| 542 |
m_root = root; |
| 543 |
} |
| 544 |
|
| 545 |
AccessibilityRootAtspi* AccessibilityObjectAtspi::root() const |
| 546 |
{ |
| 547 |
Locker locker { m_rootLock }; |
| 548 |
return m_root; |
| 549 |
} |
536 |
} |
| 550 |
|
537 |
|
| 551 |
void AccessibilityObjectAtspi::setParent(std::optional<AccessibilityObjectAtspi*> atspiParent) |
538 |
void AccessibilityObjectAtspi::setParent(std::optional<AccessibilityObjectAtspi*> atspiParent) |
|
Lines 569-578
std::optional<AccessibilityObjectAtspi*> AccessibilityObjectAtspi::parent() cons
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec10
|
| 569 |
if (!axParent) |
556 |
if (!axParent) |
| 570 |
return nullptr; |
557 |
return nullptr; |
| 571 |
|
558 |
|
| 572 |
if (auto* atspiParent = axParent->wrapper()) { |
559 |
if (auto* atspiParent = axParent->wrapper()) |
| 573 |
atspiParent->setRoot(root()); |
|
|
| 574 |
return atspiParent; |
560 |
return atspiParent; |
| 575 |
} |
|
|
| 576 |
|
561 |
|
| 577 |
return std::nullopt; |
562 |
return std::nullopt; |
| 578 |
} |
563 |
} |
|
Lines 581-590
GVariant* AccessibilityObjectAtspi::parentReference() const
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec11
|
| 581 |
{ |
566 |
{ |
| 582 |
auto parentAtspi = parent(); |
567 |
auto parentAtspi = parent(); |
| 583 |
if (!parentAtspi) |
568 |
if (!parentAtspi) |
| 584 |
return root()->atspi().nullReference(); |
569 |
return m_root.atspi().nullReference(); |
| 585 |
|
570 |
|
| 586 |
if (!parentAtspi.value()) |
571 |
if (!parentAtspi.value()) |
| 587 |
return root()->reference(); |
572 |
return m_root.reference(); |
| 588 |
|
573 |
|
| 589 |
return parentAtspi.value()->reference(); |
574 |
return parentAtspi.value()->reference(); |
| 590 |
} |
575 |
} |
|
Lines 608-628
AccessibilityObjectAtspi* AccessibilityObjectAtspi::childAt(unsigned index) cons
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec12
|
| 608 |
if (index >= children.size()) |
593 |
if (index >= children.size()) |
| 609 |
return nullptr; |
594 |
return nullptr; |
| 610 |
|
595 |
|
| 611 |
auto* wrapper = children[index]->wrapper(); |
596 |
return children[index]->wrapper(); |
| 612 |
wrapper->setRoot(root()); |
|
|
| 613 |
return wrapper; |
| 614 |
} |
597 |
} |
| 615 |
|
598 |
|
| 616 |
Vector<RefPtr<AccessibilityObjectAtspi>> AccessibilityObjectAtspi::wrapperVector(const Vector<RefPtr<AXCoreObject>>& elements) const |
599 |
Vector<RefPtr<AccessibilityObjectAtspi>> AccessibilityObjectAtspi::wrapperVector(const Vector<RefPtr<AXCoreObject>>& elements) const |
| 617 |
{ |
600 |
{ |
| 618 |
Vector<RefPtr<AccessibilityObjectAtspi>> wrappers; |
601 |
Vector<RefPtr<AccessibilityObjectAtspi>> wrappers; |
| 619 |
wrappers.reserveInitialCapacity(elements.size()); |
602 |
wrappers.reserveInitialCapacity(elements.size()); |
| 620 |
auto* root = this->root(); |
|
|
| 621 |
for (const auto& element : elements) { |
603 |
for (const auto& element : elements) { |
| 622 |
if (auto* wrapper = element->wrapper()) { |
604 |
if (auto* wrapper = element->wrapper()) |
| 623 |
wrapper->setRoot(root); |
|
|
| 624 |
wrappers.uncheckedAppend(wrapper); |
605 |
wrappers.uncheckedAppend(wrapper); |
| 625 |
} |
|
|
| 626 |
} |
606 |
} |
| 627 |
return wrappers; |
607 |
return wrappers; |
| 628 |
} |
608 |
} |
|
Lines 1140-1149
void AccessibilityObjectAtspi::buildRelationSet(GVariantBuilder* builder) const
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec13
|
| 1140 |
|
1120 |
|
| 1141 |
for (const auto& it : relationMap) { |
1121 |
for (const auto& it : relationMap) { |
| 1142 |
GVariantBuilder arrayBuilder = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE("a(so)")); |
1122 |
GVariantBuilder arrayBuilder = G_VARIANT_BUILDER_INIT(G_VARIANT_TYPE("a(so)")); |
| 1143 |
for (const auto& atspiObject : it.value) { |
1123 |
for (const auto& atspiObject : it.value) |
| 1144 |
atspiObject->setRoot(root()); |
|
|
| 1145 |
g_variant_builder_add(&arrayBuilder, "@(so)", atspiObject->reference()); |
1124 |
g_variant_builder_add(&arrayBuilder, "@(so)", atspiObject->reference()); |
| 1146 |
} |
|
|
| 1147 |
g_variant_builder_add(builder, "(ua(so))", it.key, &arrayBuilder); |
1125 |
g_variant_builder_add(builder, "(ua(so))", it.key, &arrayBuilder); |
| 1148 |
} |
1126 |
} |
| 1149 |
} |
1127 |
} |
|
Lines 1180-1188
void AccessibilityObjectAtspi::buildInterfaces(GVariantBuilder* builder) const
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec14
|
| 1180 |
void AccessibilityObjectAtspi::serialize(GVariantBuilder* builder) const |
1158 |
void AccessibilityObjectAtspi::serialize(GVariantBuilder* builder) const |
| 1181 |
{ |
1159 |
{ |
| 1182 |
RELEASE_ASSERT(!isMainThread()); |
1160 |
RELEASE_ASSERT(!isMainThread()); |
| 1183 |
auto* atspiRoot = root(); |
1161 |
g_variant_builder_add(builder, "(so)", m_root.atspi().uniqueName(), m_path.utf8().data()); |
| 1184 |
g_variant_builder_add(builder, "(so)", atspiRoot->atspi().uniqueName(), m_path.utf8().data()); |
1162 |
g_variant_builder_add(builder, "(so)", m_root.parentUniqueName().utf8().data(), "/org/a11y/atspi/accessible/root"); |
| 1185 |
g_variant_builder_add(builder, "(so)", atspiRoot->parentUniqueName().utf8().data(), "/org/a11y/atspi/accessible/root"); |
|
|
| 1186 |
g_variant_builder_add(builder, "@(so)", parentReference()); |
1163 |
g_variant_builder_add(builder, "@(so)", parentReference()); |
| 1187 |
|
1164 |
|
| 1188 |
g_variant_builder_add(builder, "i", indexInParent()); |
1165 |
g_variant_builder_add(builder, "i", indexInParent()); |
|
Lines 1214-1220
void AccessibilityObjectAtspi::childAdded(AccessibilityObjectAtspi& child)
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec15
|
| 1214 |
RunLoop::main().dispatch([this, protectedThis = Ref { *this }, child = Ref { child }] { |
1191 |
RunLoop::main().dispatch([this, protectedThis = Ref { *this }, child = Ref { child }] { |
| 1215 |
if (!m_coreObject) |
1192 |
if (!m_coreObject) |
| 1216 |
return; |
1193 |
return; |
| 1217 |
root()->atspi().childrenChanged(*this, child, AccessibilityAtspi::ChildrenChanged::Added); |
1194 |
m_root.atspi().childrenChanged(*this, child, AccessibilityAtspi::ChildrenChanged::Added); |
| 1218 |
}); |
1195 |
}); |
| 1219 |
} |
1196 |
} |
| 1220 |
|
1197 |
|
|
Lines 1224-1230
void AccessibilityObjectAtspi::childRemoved(AccessibilityObjectAtspi& child)
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec16
|
| 1224 |
if (!m_isRegistered.load()) |
1201 |
if (!m_isRegistered.load()) |
| 1225 |
return; |
1202 |
return; |
| 1226 |
|
1203 |
|
| 1227 |
root()->atspi().childrenChanged(*this, child, AccessibilityAtspi::ChildrenChanged::Removed); |
1204 |
m_root.atspi().childrenChanged(*this, child, AccessibilityAtspi::ChildrenChanged::Removed); |
| 1228 |
} |
1205 |
} |
| 1229 |
|
1206 |
|
| 1230 |
void AccessibilityObjectAtspi::stateChanged(const char* name, bool value) |
1207 |
void AccessibilityObjectAtspi::stateChanged(const char* name, bool value) |
|
Lines 1233-1239
void AccessibilityObjectAtspi::stateChanged(const char* name, bool value)
a/Source/WebCore/accessibility/atspi/AccessibilityObjectAtspi.cpp_sec17
|
| 1233 |
if (!m_isRegistered.load()) |
1210 |
if (!m_isRegistered.load()) |
| 1234 |
return; |
1211 |
return; |
| 1235 |
|
1212 |
|
| 1236 |
root()->atspi().stateChanged(*this, name, value); |
1213 |
m_root.atspi().stateChanged(*this, name, value); |
| 1237 |
} |
1214 |
} |
| 1238 |
|
1215 |
|
| 1239 |
unsigned AccessibilityObjectAtspi::role() const |
1216 |
unsigned AccessibilityObjectAtspi::role() const |