Skip to content

Commit

Permalink
Replace WebAXObject access in WebView.
Browse files Browse the repository at this point in the history
A WebAXObject static function does the job now.

Bug: 71532
Change-Id: I4ca95eeee1bb9481fbf3713f759d9366f83de750
Reviewed-on: https://chromium-review.googlesource.com/520363
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Stuart Langley <slangley@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#476253}
  • Loading branch information
Nicholas Verne authored and Commit Bot committed Jun 1, 2017
1 parent 03f4a0e commit daef9d4
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 17 deletions.
8 changes: 5 additions & 3 deletions content/shell/test_runner/accessibility_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,20 @@ v8::Local<v8::Object> 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<v8::Object> 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<v8::Object> 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<v8::Object>();
Expand Down
11 changes: 11 additions & 0 deletions third_party/WebKit/Source/web/WebAXObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
8 changes: 0 additions & 8 deletions third_party/WebKit/Source/web/WebViewImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion third_party/WebKit/Source/web/WebViewImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions third_party/WebKit/public/web/WebAXObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class WebNode;
class WebDocument;
class WebString;
class WebURL;
class WebView;
struct WebFloatRect;
struct WebPoint;
struct WebRect;
Expand Down Expand Up @@ -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&);
Expand Down
5 changes: 0 additions & 5 deletions third_party/WebKit/public/web/WebView.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ICCProfile;

namespace blink {

class WebAXObject;
class WebCredentialManagerClient;
class WebFrame;
class WebHitTestResult;
Expand Down Expand Up @@ -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 --------------------------------------------------------

Expand Down

0 comments on commit daef9d4

Please sign in to comment.