Commit d6b6aa73 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch AxObjectCacheBase to use downcast helpers

AxObjectCacheBase is the only direct subclass of AxObjectCache,
so it is safe to unconditionally downcast from later to the former.

This CL enforces that premise by making AxObjectCache's ctor private,
and stating AxObjectCacheBase as a friend class of it.

Additionally, the CL:
- removes the macro-based cast helper ToAXObjectCacheBase from being
used in t_p/blink/renderer/core/editing/finder/text_finder.cc, and
uses implicit cast.

- switches t_p/blink/renderer/core/exported/web_page_popup_impl.cc
to use the newly added downcast trait helper.

BUG=891908

Change-Id: Iab8f129b1bd330306b1761de58bc4b17ee2ed6a8
Reviewed-on: https://chromium-review.googlesource.com/c/1494677Reviewed-by: default avatarSergio Villar <svillar@igalia.com>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#636460}
parent 315f254a
......@@ -142,10 +142,10 @@ class CORE_EXPORT AXObjectCache
// Static helper functions.
static bool IsInsideFocusableElementOrARIAWidget(const Node&);
protected:
private:
friend class AXObjectCacheBase;
AXObjectCache(Document&);
private:
static AXObjectCacheCreateFunction create_function_;
DISALLOW_COPY_AND_ASSIGN(AXObjectCache);
};
......
......@@ -8,6 +8,7 @@
#include "base/macros.h"
#include "third_party/blink/renderer/core/accessibility/ax_object_cache.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -33,8 +34,12 @@ class CORE_EXPORT AXObjectCacheBase : public AXObjectCache {
DISALLOW_COPY_AND_ASSIGN(AXObjectCacheBase);
};
// This is the only subclass of AXObjectCache.
DEFINE_TYPE_CASTS(AXObjectCacheBase, AXObjectCache, cache, true, true);
template <>
struct DowncastTraits<AXObjectCacheBase> {
// All concrete implementations of AXObjectCache are derived from
// AXObjectCacheBase.
static bool AllowFrom(const AXObjectCache& cache) { return true; }
};
} // namespace blink
......
......@@ -322,8 +322,8 @@ void TextFinder::ReportFindInPageResultToAccessibility(int identifier) {
if (!active_match_)
return;
AXObjectCacheBase* ax_object_cache = ToAXObjectCacheBase(
OwnerFrame().GetFrame()->GetDocument()->ExistingAXObjectCache());
auto* ax_object_cache =
OwnerFrame().GetFrame()->GetDocument()->ExistingAXObjectCache();
if (!ax_object_cache)
return;
......
......@@ -352,7 +352,7 @@ AXObject* WebPagePopupImpl::RootAXObject() {
// and the AXObjectCache doesn't already exist. It's called when trying
// to attach the accessibility tree of the pop-up to the host page.
DCHECK(cache);
return ToAXObjectCacheBase(cache)->GetOrCreate(document->GetLayoutView());
return To<AXObjectCacheBase>(cache)->GetOrCreate(document->GetLayoutView());
}
void WebPagePopupImpl::SetWindowRect(const IntRect& rect_in_screen) {
......
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