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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXObject.cpp

Issue 2088453002: Implement the inert attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Logspammy WIP Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/AXObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
index 8d63c1deefbc2c861232ce9c90c4efa39f7015e0..03c202e30312edf1d218bcda97bf1a3b4e16361b 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXObject.cpp
@@ -29,6 +29,7 @@
#include "modules/accessibility/AXObject.h"
#include "SkMatrix44.h"
+#include "base/debug/stack_trace.h"
#include "core/InputTypeNames.h"
#include "core/css/resolver/StyleResolver.h"
#include "core/dom/AccessibleNode.h"
@@ -533,7 +534,19 @@ bool AXObject::IsClickable() const {
}
}
-bool AXObject::AccessibilityIsIgnored() const {
+bool AXObject::AccessibilityIsIgnored() {
+ Document* document = GetDocument();
+ if (!document) {
+ LOG(INFO) << "no document";
+ }
+ while (document) {
+ document->UpdateDistribution();
+ if (!document->ownerDocument() && document->LocalOwner())
+ document = document->LocalOwner()->ownerDocument();
+ else
+ document = nullptr; // Only walk up the chain for <object>
+ }
+
UpdateCachedAttributeValuesIfNeeded();
return cached_is_ignored_;
}
@@ -615,10 +628,15 @@ bool AXObject::ComputeIsInertOrAriaHidden(
ignored_reasons->push_back(
IgnoredReason(kAXActiveModalDialog, dialog_object));
else
- ignored_reasons->push_back(IgnoredReason(kAXInert));
+ ignored_reasons->push_back(IgnoredReason(kAXInertElement));
} else {
- // TODO(aboxhall): handle inert attribute if it eventuates
- ignored_reasons->push_back(IgnoredReason(kAXInert));
+ const AXObject* inert_root_el = InertRoot();
+ if (inert_root_el == this) {
+ ignored_reasons->push_back(IgnoredReason(kAXInertElement));
+ } else {
+ ignored_reasons->push_back(
+ IgnoredReason(kAXInertSubtree, inert_root_el));
+ }
}
}
return true;
@@ -635,11 +653,12 @@ bool AXObject::ComputeIsInertOrAriaHidden(
const AXObject* hidden_root = AriaHiddenRoot();
if (hidden_root) {
if (ignored_reasons) {
- if (hidden_root == this)
- ignored_reasons->push_back(IgnoredReason(kAXAriaHidden));
- else
+ if (hidden_root == this) {
+ ignored_reasons->push_back(IgnoredReason(kAXAriaHiddenElement));
+ } else {
ignored_reasons->push_back(
- IgnoredReason(kAXAriaHiddenRoot, hidden_root));
+ IgnoredReason(kAXAriaHiddenSubtree, hidden_root));
+ }
}
return true;
}
@@ -672,6 +691,26 @@ const AXObject* AXObject::AriaHiddenRoot() const {
return 0;
}
+const AXObject* AXObject::InertRoot() const {
+ const AXObject* object = this;
+ if (!RuntimeEnabledFeatures::inertAttributeEnabled())
+ return 0;
+
+ while (object && !object->IsAXNodeObject())
+ object = object->ParentObject();
+ Node* node = object->GetNode();
+ Element* element = node->IsElementNode()
+ ? ToElement(node)
+ : FlatTreeTraversal::ParentElement(*node);
+ while (element) {
+ if (element->hasAttribute(inertAttr))
+ return AxObjectCache().GetOrCreate(element);
+ element = FlatTreeTraversal::ParentElement(*element);
+ }
+
+ return 0;
+}
+
bool AXObject::IsDescendantOfDisabledNode() const {
UpdateCachedAttributeValuesIfNeeded();
return cached_is_descendant_of_disabled_node_;
@@ -1225,11 +1264,19 @@ Document* AXObject::GetDocument() const {
FrameView* AXObject::DocumentFrameView() const {
const AXObject* object = this;
- while (object && !object->IsAXLayoutObject())
+ LOG(INFO) << "DocumentFrameView for " << RoleName(RoleValue()).Utf8().data();
+ base::debug::StackTrace trace;
+ trace.Print();
+
+ while (object && !object->IsAXLayoutObject()) {
object = object->ParentObject();
+ LOG(INFO) << "parent: " << (object ? RoleName(object->RoleValue()).Utf8().data() : "null");
+ }
- if (!object)
+ if (!object) {
+ LOG(INFO) << "No candidate layout object in parent hierarchy";
return 0;
+ }
return object->DocumentFrameView();
}
@@ -1868,4 +1915,5 @@ DEFINE_TRACE(AXObject) {
visitor->Trace(ax_object_cache_);
}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698