Commit 17292b4f authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for {ChromeClient,AXObjectCache}Impl classes.

Bug: 891908
Change-Id: Ic6acd1540de40b3595252a1c1c493e6d7063cfbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1997363Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#730906}
parent 4f54803d
......@@ -290,11 +290,12 @@ class CORE_EXPORT ChromeClientImpl final : public ChromeClient {
FRIEND_TEST_ALL_PREFIXES(FileChooserQueueTest, DerefQueuedChooser);
};
DEFINE_TYPE_CASTS(ChromeClientImpl,
ChromeClient,
client,
client->IsChromeClientImpl(),
client.IsChromeClientImpl());
template <>
struct DowncastTraits<ChromeClientImpl> {
static bool AllowFrom(const ChromeClient& client) {
return client.IsChromeClientImpl();
}
};
} // namespace blink
......
......@@ -79,7 +79,7 @@ class CreateWindowTest : public testing::Test {
web_view_ = helper_.Initialize(nullptr, &web_view_client_);
main_frame_ = helper_.LocalMainFrame();
chrome_client_impl_ =
ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient());
To<ChromeClientImpl>(&web_view_->GetPage()->GetChromeClient());
}
ViewCreatingClient web_view_client_;
......@@ -186,7 +186,7 @@ class PagePopupSuppressionTest : public testing::Test {
web_view_ = helper_.Initialize();
main_frame_ = helper_.LocalMainFrame();
chrome_client_impl_ =
ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient());
To<ChromeClientImpl>(&web_view_->GetPage()->GetChromeClient());
LocalFrame* frame = helper_.LocalMainFrame()->GetFrame();
color_chooser_client_ = MakeGarbageCollected<FakeColorChooserClient>(
frame->GetDocument()->documentElement());
......@@ -258,7 +258,7 @@ class FileChooserQueueTest : public testing::Test {
void SetUp() override {
web_view_ = helper_.Initialize();
chrome_client_impl_ =
ToChromeClientImpl(&web_view_->GetPage()->GetChromeClient());
To<ChromeClientImpl>(&web_view_->GetPage()->GetChromeClient());
}
frame_test_helpers::WebViewHelper helper_;
......
......@@ -419,7 +419,10 @@ class MODULES_EXPORT AXObjectCacheImpl
};
// This is the only subclass of AXObjectCache.
DEFINE_TYPE_CASTS(AXObjectCacheImpl, AXObjectCache, cache, true, true);
template <>
struct DowncastTraits<AXObjectCacheImpl> {
static bool AllowFrom(const AXObjectCache& cache) { return true; }
};
// This will let you know if aria-hidden was explicitly set to false.
bool IsNodeAriaVisible(Node*);
......
......@@ -534,7 +534,7 @@ Response InspectorAccessibilityAgent::getPartialAXTree(
if (!local_frame)
return Response::Error("Frame is detached.");
AXContext ax_context(document);
AXObjectCacheImpl& cache = ToAXObjectCacheImpl(ax_context.GetAXObjectCache());
auto& cache = To<AXObjectCacheImpl>(ax_context.GetAXObjectCache());
AXObject* inspected_ax_object = cache.GetOrCreate(dom_node);
*nodes = std::make_unique<protocol::Array<protocol::Accessibility::AXNode>>();
......@@ -723,7 +723,7 @@ Response InspectorAccessibilityAgent::getFullAXTree(
document->UpdateStyleAndLayout();
*nodes = std::make_unique<protocol::Array<protocol::Accessibility::AXNode>>();
AXContext ax_context(*document);
AXObjectCacheImpl& cache = ToAXObjectCacheImpl(ax_context.GetAXObjectCache());
auto& cache = To<AXObjectCacheImpl>(ax_context.GetAXObjectCache());
Deque<AXID> ids;
ids.emplace_back(cache.Root()->AXObjectID());
while (!ids.empty()) {
......
......@@ -25,7 +25,7 @@ void AccessibilityTest::SetUp() {
AXObjectCacheImpl& AccessibilityTest::GetAXObjectCache() const {
auto* ax_object_cache =
ToAXObjectCacheImpl(GetDocument().ExistingAXObjectCache());
To<AXObjectCacheImpl>(GetDocument().ExistingAXObjectCache());
DCHECK(ax_object_cache);
return *ax_object_cache;
}
......
......@@ -338,8 +338,8 @@ TEST_F(CanvasRenderingContext2DAPITest, AccessibilityRectTestForAddHitRegion) {
context->rect(10, 10, 40, 40);
context->addHitRegion(options, exception_state);
AXObjectCacheImpl* ax_object_cache =
ToAXObjectCacheImpl(GetDocument().ExistingAXObjectCache());
auto* ax_object_cache =
To<AXObjectCacheImpl>(GetDocument().ExistingAXObjectCache());
AXObject* ax_object = ax_object_cache->GetOrCreate(button_element);
LayoutRect ax_bounds = ax_object->GetBoundsInFrameCoordinates();
......@@ -365,8 +365,8 @@ TEST_F(CanvasRenderingContext2DAPITest,
context->rect(10, 10, 40, 40);
context->drawFocusIfNeeded(button_element);
AXObjectCacheImpl* ax_object_cache =
ToAXObjectCacheImpl(GetDocument().ExistingAXObjectCache());
auto* ax_object_cache =
To<AXObjectCacheImpl>(GetDocument().ExistingAXObjectCache());
AXObject* ax_object = ax_object_cache->GetOrCreate(button_element);
LayoutRect ax_bounds = ax_object->GetBoundsInFrameCoordinates();
......
......@@ -1721,7 +1721,7 @@ WebAXObject::operator AXObject*() const {
WebAXObject WebAXObject::FromWebNode(const WebNode& web_node) {
WebDocument web_document = web_node.GetDocument();
const Document* doc = web_document.ConstUnwrap<Document>();
AXObjectCacheImpl* cache = ToAXObjectCacheImpl(doc->ExistingAXObjectCache());
auto* cache = To<AXObjectCacheImpl>(doc->ExistingAXObjectCache());
const Node* node = web_node.ConstUnwrap<Node>();
return cache ? WebAXObject(cache->Get(node)) : WebAXObject();
}
......@@ -1729,8 +1729,7 @@ WebAXObject WebAXObject::FromWebNode(const WebNode& web_node) {
// static
WebAXObject WebAXObject::FromWebDocument(const WebDocument& web_document) {
const Document* document = web_document.ConstUnwrap<Document>();
AXObjectCacheImpl* cache =
ToAXObjectCacheImpl(document->ExistingAXObjectCache());
auto* cache = To<AXObjectCacheImpl>(document->ExistingAXObjectCache());
return cache ? WebAXObject(cache->GetOrCreate(document->GetLayoutView()))
: WebAXObject();
}
......@@ -1739,8 +1738,7 @@ WebAXObject WebAXObject::FromWebDocument(const WebDocument& web_document) {
WebAXObject WebAXObject::FromWebDocumentByID(const WebDocument& web_document,
int ax_id) {
const Document* document = web_document.ConstUnwrap<Document>();
AXObjectCacheImpl* cache =
ToAXObjectCacheImpl(document->ExistingAXObjectCache());
auto* cache = To<AXObjectCacheImpl>(document->ExistingAXObjectCache());
return cache ? WebAXObject(cache->ObjectFromAXID(ax_id)) : WebAXObject();
}
......@@ -1748,8 +1746,7 @@ WebAXObject WebAXObject::FromWebDocumentByID(const WebDocument& web_document,
WebAXObject WebAXObject::FromWebDocumentFocused(
const WebDocument& web_document) {
const Document* document = web_document.ConstUnwrap<Document>();
AXObjectCacheImpl* cache =
ToAXObjectCacheImpl(document->ExistingAXObjectCache());
auto* cache = To<AXObjectCacheImpl>(document->ExistingAXObjectCache());
return cache ? WebAXObject(cache->FocusedObject()) : WebAXObject();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment