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

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

Issue 2745713002: WIP: Modified AXPosition to work with objects with both embedded object characters and text. (Closed)
Patch Set: Simplified and cleaned up selection code in Blink > Accessibility. Created 3 years, 6 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/AXNodeObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
index c52d572336f4fc9625ad4609ec77a094f2b0086b..a189a1c9b66492df94a63ca91cd3a863a73bca03 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXNodeObject.cpp
@@ -1418,8 +1418,9 @@ void AXNodeObject::Markers(Vector<DocumentMarker::MarkerType>& marker_types,
case DocumentMarker::kTextMatch:
case DocumentMarker::kActiveSuggestion:
marker_types.push_back(marker->GetType());
- marker_ranges.push_back(
- AXRange(marker->StartOffset(), marker->EndOffset()));
+ marker_ranges.emplace_back(
+ const_cast<AXNodeObject*>(this), marker->StartOffset(),
+ const_cast<AXNodeObject*>(this), marker->EndOffset());
break;
case DocumentMarker::kComposition:
// No need for accessibility to know about these marker types.
@@ -2018,6 +2019,32 @@ bool AXNodeObject::NameFromLabelElement() const {
return false;
}
+bool AXNodeObject::NameFromContents() const {
+ Node* node = GetNode();
+ if (!node || !node->IsElementNode())
+ return AXObject::NameFromContents();
+ // AXObject::nameFromContents determines whether an element should take its
+ // name from its descendant contents based on role. However, <select> is a
+ // special case, as unlike a typical pop-up button it contains its own pop-up
+ // menu's contents, which should not be used as the name.
+ if (isHTMLSelectElement(node))
+ return false;
+ return AXObject::NameFromContents();
+}
+
+AXRange AXNodeObject::Selection() const {
+ if (!GetNode())
+ return AXObject::Selection();
+ if (IsTextControlElement(GetNode())) {
+ TextControlElement* text_control = ToTextControlElement(GetNode());
+ return AXRange(const_cast<AXNodeObject*>(this),
+ text_control->selectionStart(),
+ const_cast<AXNodeObject*>(this),
+ text_control->selectionEnd(), TextAffinity::kDownstream);
+ }
+ return AXObject::Selection();
+}
+
void AXNodeObject::GetRelativeBounds(
AXObjectImpl** out_container,
FloatRect& out_bounds_in_container,

Powered by Google App Engine
This is Rietveld 408576698