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

Unified Diff: content/shell/test_runner/accessibility_controller.cc

Issue 2928033002: Move GetDocument method from WebFrame to WebLocalFrame. (Closed)
Patch Set: Rebasing... 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: content/shell/test_runner/accessibility_controller.cc
diff --git a/content/shell/test_runner/accessibility_controller.cc b/content/shell/test_runner/accessibility_controller.cc
index 233f8f0ec0e4c7650fef7313cf5c0b1b59c87c7c..db320eb8c8018d293181b451483435e77582c169 100644
--- a/content/shell/test_runner/accessibility_controller.cc
+++ b/content/shell/test_runner/accessibility_controller.cc
@@ -4,6 +4,8 @@
#include "content/shell/test_runner/accessibility_controller.h"
+#include <string>
+
#include "base/macros.h"
#include "content/shell/test_runner/web_view_test_proxy.h"
#include "gin/handle.h"
@@ -216,23 +218,24 @@ v8::Local<v8::Object> AccessibilityController::FocusedElement() {
if (!frame)
return v8::Local<v8::Object>();
+ CHECK(frame->IsWebLocalFrame())
+ << "This function cannot be called if the main frame is not a "
+ "local frame.";
blink::WebAXObject focused_element =
- blink::WebAXObject::FromWebDocumentFocused(frame->GetDocument());
+ blink::WebAXObject::FromWebDocumentFocused(
+ frame->ToWebLocalFrame()->GetDocument());
if (focused_element.IsNull())
- focused_element = blink::WebAXObject::FromWebView(*web_view());
+ focused_element = GetAccessibilityObjectForMainFrame();
return elements_.GetOrCreate(focused_element);
}
v8::Local<v8::Object> AccessibilityController::RootElement() {
- blink::WebAXObject root_element =
- blink::WebAXObject::FromWebView(*web_view());
- return elements_.GetOrCreate(root_element);
+ return elements_.GetOrCreate(GetAccessibilityObjectForMainFrame());
}
v8::Local<v8::Object> AccessibilityController::AccessibleElementById(
const std::string& id) {
- blink::WebAXObject root_element =
- blink::WebAXObject::FromWebView(*web_view());
+ blink::WebAXObject root_element = GetAccessibilityObjectForMainFrame();
if (!root_element.UpdateLayoutAndCheckValidity())
return v8::Local<v8::Object>();
@@ -271,4 +274,14 @@ blink::WebView* AccessibilityController::web_view() {
return web_view_test_proxy_base_->web_view();
}
+blink::WebAXObject
+AccessibilityController::GetAccessibilityObjectForMainFrame() {
+ blink::WebFrame* frame = web_view()->MainFrame();
+ CHECK(frame && frame->IsWebLocalFrame())
+ << "This function cannot be called if the main frame is not a "
+ "local frame.";
+ return blink::WebAXObject::FromWebDocument(
+ web_view()->MainFrame()->ToWebLocalFrame()->GetDocument());
+}
+
} // namespace test_runner

Powered by Google App Engine
This is Rietveld 408576698