Commit 73d2d94c authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

Switch WebFrameWidgetBase to use downcast helpers

Apart from start making use of the always-true downcast
helper, in order to ensure that WebFrameWidget is always a
WebFrameWidgetBase intance (and hence respecting the downcast
helper contract), this CL also adds a private WebFrameWidget
ctor, and make it a friend-class to WebFrameWidgetBase.

This ensures that WebFrameWidgetBase is the only concrete subclass
that implements WebFrameWidget.

R=jbroman@chromium.org
CC=blink-reviews-vendor@chromium.org

BUG=891908

Change-Id: Ibdea5aea0fcb538b15a12a7cfc00691249ef2099
Reviewed-on: https://chromium-review.googlesource.com/c/1490291
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636234}
parent 0547b535
......@@ -132,6 +132,13 @@ class WebFrameWidget : public WebWidget {
// This function provides zooming for find in page results when browsing with
// page autosize.
virtual void ZoomToFindInPageRect(const WebRect& rect_in_root_frame) = 0;
private:
// This private constructor and the class/friend declaration ensures that
// WebFrameWidgetBase is the only concrete subclass that implements
// WebFrameWidget, so that it is safe to downcast to WebFrameWidgetBase.
friend class WebFrameWidgetBase;
WebFrameWidget() = default;
};
} // namespace blink
......
......@@ -214,7 +214,7 @@ class PagePopupChromeClient final : public EmptyChromeClient {
WebFrameWidget* widget = web_frame->LocalRoot()->FrameWidget();
if (!widget)
return;
if (WebWidgetClient* client = ToWebFrameWidgetBase(widget)->Client())
if (WebWidgetClient* client = To<WebFrameWidgetBase>(widget)->Client())
client->SetTouchAction(static_cast<WebTouchAction>(touch_action));
}
......
......@@ -16,6 +16,7 @@
#include "third_party/blink/renderer/core/dom/user_gesture_indicator.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_image.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace cc {
class AnimationHost;
......@@ -200,7 +201,12 @@ class CORE_EXPORT WebFrameWidgetBase
friend class WebViewImpl;
};
DEFINE_TYPE_CASTS(WebFrameWidgetBase, WebFrameWidget, widget, true, true);
template <>
struct DowncastTraits<WebFrameWidgetBase> {
// All concrete implementations of WebFrameWidget are derived from
// WebFrameWidgetBase.
static bool AllowFrom(const WebFrameWidget& widget) { return true; }
};
} // namespace blink
......
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