diff --git a/content/shell/test_runner/accessibility_controller.cc b/content/shell/test_runner/accessibility_controller.cc index efd270badd3864..9180f7653ac80d 100644 --- a/content/shell/test_runner/accessibility_controller.cc +++ b/content/shell/test_runner/accessibility_controller.cc @@ -218,18 +218,20 @@ v8::Local AccessibilityController::FocusedElement() { blink::WebAXObject focused_element = frame->GetDocument().FocusedAccessibilityObject(); if (focused_element.IsNull()) - focused_element = web_view()->AccessibilityObject(); + focused_element = blink::WebAXObject::FromWebView(*web_view()); return elements_.GetOrCreate(focused_element); } v8::Local AccessibilityController::RootElement() { - blink::WebAXObject root_element = web_view()->AccessibilityObject(); + blink::WebAXObject root_element = + blink::WebAXObject::FromWebView(*web_view()); return elements_.GetOrCreate(root_element); } v8::Local AccessibilityController::AccessibleElementById( const std::string& id) { - blink::WebAXObject root_element = web_view()->AccessibilityObject(); + blink::WebAXObject root_element = + blink::WebAXObject::FromWebView(*web_view()); if (!root_element.UpdateLayoutAndCheckValidity()) return v8::Local(); diff --git a/third_party/WebKit/Source/web/WebAXObject.cpp b/third_party/WebKit/Source/web/WebAXObject.cpp index 7320af9a8163cf..5e767dcd96d81e 100644 --- a/third_party/WebKit/Source/web/WebAXObject.cpp +++ b/third_party/WebKit/Source/web/WebAXObject.cpp @@ -58,6 +58,7 @@ #include "public/web/WebDocument.h" #include "public/web/WebElement.h" #include "public/web/WebNode.h" +#include "public/web/WebView.h" namespace blink { @@ -1569,4 +1570,14 @@ WebAXObject WebAXObject::FromWebNode(WebNode& web_node) { return cache ? WebAXObject(cache->Get(node)) : WebAXObject(); } +// static +WebAXObject WebAXObject::FromWebView(WebView& web_view) { + auto main_frame = web_view.MainFrame(); + if (!main_frame) + return WebAXObject(); + + Document* document = main_frame->GetDocument(); + return WebAXObject(ToAXObjectCacheImpl(document->AxObjectCache())->Root()); +} + } // namespace blink diff --git a/third_party/WebKit/Source/web/WebViewImpl.cpp b/third_party/WebKit/Source/web/WebViewImpl.cpp index b802dabbebd19a..0b27aeb12bd814 100644 --- a/third_party/WebKit/Source/web/WebViewImpl.cpp +++ b/third_party/WebKit/Source/web/WebViewImpl.cpp @@ -3460,14 +3460,6 @@ void WebViewImpl::DisableDeviceEmulation() { dev_tools_emulator_->DisableDeviceEmulation(); } -WebAXObject WebViewImpl::AccessibilityObject() { - if (!MainFrameImpl()) - return WebAXObject(); - - Document* document = MainFrameImpl()->GetFrame()->GetDocument(); - return WebAXObject(ToAXObjectCacheImpl(document->AxObjectCache())->Root()); -} - void WebViewImpl::PerformCustomContextMenuAction(unsigned action) { if (!page_) return; diff --git a/third_party/WebKit/Source/web/WebViewImpl.h b/third_party/WebKit/Source/web/WebViewImpl.h index 6e47532318a1e1..4b0a1165903512 100644 --- a/third_party/WebKit/Source/web/WebViewImpl.h +++ b/third_party/WebKit/Source/web/WebViewImpl.h @@ -223,7 +223,6 @@ class WEB_EXPORT WebViewImpl final unsigned long CreateUniqueIdentifierForRequest() override; void EnableDeviceEmulation(const WebDeviceEmulationParams&) override; void DisableDeviceEmulation() override; - WebAXObject AccessibilityObject() override; void SetSelectionColors(unsigned active_background_color, unsigned active_foreground_color, unsigned inactive_background_color, diff --git a/third_party/WebKit/public/web/WebAXObject.h b/third_party/WebKit/public/web/WebAXObject.h index 37d0d43c9c9ead..c21bc2f247438b 100644 --- a/third_party/WebKit/public/web/WebAXObject.h +++ b/third_party/WebKit/public/web/WebAXObject.h @@ -50,6 +50,7 @@ class WebNode; class WebDocument; class WebString; class WebURL; +class WebView; struct WebFloatRect; struct WebPoint; struct WebRect; @@ -94,6 +95,7 @@ class WebAXObject { } BLINK_EXPORT static WebAXObject FromWebNode(WebNode&); + BLINK_EXPORT static WebAXObject FromWebView(WebView&); BLINK_EXPORT void Reset(); BLINK_EXPORT void Assign(const WebAXObject&); diff --git a/third_party/WebKit/public/web/WebView.h b/third_party/WebKit/public/web/WebView.h index d65c95538989fd..467099746c508b 100644 --- a/third_party/WebKit/public/web/WebView.h +++ b/third_party/WebKit/public/web/WebView.h @@ -46,7 +46,6 @@ class ICCProfile; namespace blink { -class WebAXObject; class WebCredentialManagerClient; class WebFrame; class WebHitTestResult; @@ -370,10 +369,6 @@ class WebView : protected WebWidget { // Cancel emulation started via |enableDeviceEmulation| call. virtual void DisableDeviceEmulation() = 0; - // Accessibility ------------------------------------------------------- - - // Returns the accessibility object for this view. - virtual WebAXObject AccessibilityObject() = 0; // Context menu --------------------------------------------------------