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

Unified Diff: components/test_runner/web_ax_object_proxy.cc

Issue 1195223006: Reports the position of the caret and current selection in content editables. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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: components/test_runner/web_ax_object_proxy.cc
diff --git a/components/test_runner/web_ax_object_proxy.cc b/components/test_runner/web_ax_object_proxy.cc
index 4ed30f2c44ff2f737e8eacd565882a5ad4a9af0c..c22cdc31f31e781b34791f95ec63252664313947 100644
--- a/components/test_runner/web_ax_object_proxy.cc
+++ b/components/test_runner/web_ax_object_proxy.cc
@@ -492,6 +492,14 @@ WebAXObjectProxy::GetObjectTemplateBuilder(v8::Isolate* isolate) {
.SetProperty("maxValue", &WebAXObjectProxy::MaxValue)
.SetProperty("valueDescription", &WebAXObjectProxy::ValueDescription)
.SetProperty("childrenCount", &WebAXObjectProxy::ChildrenCount)
+ .SetProperty("selectionAnchorObject",
+ &WebAXObjectProxy::SelectionAnchorObject)
+ .SetProperty("selectionAnchorOffset",
+ &WebAXObjectProxy::SelectionAnchorOffset)
+ .SetProperty("selectionFocusObject",
+ &WebAXObjectProxy::SelectionFocusObject)
+ .SetProperty("selectionFocusOffset",
+ &WebAXObjectProxy::SelectionFocusOffset)
.SetProperty("selectionStart", &WebAXObjectProxy::SelectionStart)
.SetProperty("selectionEnd", &WebAXObjectProxy::SelectionEnd)
.SetProperty("selectionStartLineNumber",
@@ -733,6 +741,66 @@ int WebAXObjectProxy::ChildrenCount() {
return count;
}
+v8::Local<v8::Object> WebAXObjectProxy::SelectionAnchorObject() {
+ accessibility_object_.updateLayoutAndCheckValidity();
+
+ blink::WebAxObject* anchorObject = nullptr;
dmazzoni 2015/06/22 19:23:21 Typo: WebAxObject -> WebAXObject
+ int anchorOffset = -1;
+ blink::WebAxObject* focusObject = nullptr;
+ int focusOffset = -1;
+ accessibility_object_.selection(anchorObject, &anchorOffset,
+ focusObject, &focusOffset);
+ if (anchorObject)
+ return factory_->GetOrCreate(anchorObject);
+
+ return v8::Local<v8::Object>();
+}
+
+int WebAXObjectProxy::SelectionAnchorOffset() {
+ accessibility_object_.updateLayoutAndCheckValidity();
+
+ blink::WebAxObject* anchorObject = nullptr;
+ int anchorOffset = -1;
+ blink::WebAxObject* focusObject = nullptr;
+ int focusOffset = -1;
+ accessibility_object_.selection(anchorObject, &anchorOffset,
+ focusObject, &focusOffset);
+ if (anchorOffset >= 0)
+ return anchorOffset;
+
+ return -1;
+}
+
+v8::Local<v8::Object> WebAXObjectProxy::SelectionFocusObject() {
+ accessibility_object_.updateLayoutAndCheckValidity();
+
+ blink::WebAxObject* anchorObject = nullptr;
+ int anchorOffset = -1;
+ blink::WebAxObject* focusObject = nullptr;
+ int focusOffset = -1;
+ accessibility_object_.selection(anchorObject, &anchorOffset,
+ focusObject, &focusOffset);
+ if (focusObject)
+ return factory_->GetOrCreate(focusObject);
+
+ return v8::Local<v8::Object>();
+}
+
+int WebAXObjectProxy::SelectionFocusOffset() {
+ accessibility_object_.updateLayoutAndCheckValidity();
+
+ blink::WebAxObject* anchorObject = nullptr;
+ int anchorOffset = -1;
+ blink::WebAxObject* focusObject = nullptr;
+ int focusOffset = -1;
+ accessibility_object_.selection(anchorObject, &anchorOffset,
+ focusObject, &focusOffset);
+ if (focusOffset >= 0)
+ return focusOffset;
+
+ return -1;
+}
+
int WebAXObjectProxy::SelectionStart() {
accessibility_object_.updateLayoutAndCheckValidity();
return accessibility_object_.selectionStart();

Powered by Google App Engine
This is Rietveld 408576698