Commit 15476cef authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Clean up calls to RenderWidget::GetWebWidget().

All calls to GetWebWidget() should either DCHECK that the WebWidget exists, or
else have a conditional with appropriate behavior if the WebWidget does not.

Bug: 995981
Change-Id: I32e148efe04c5a889b0b26ad1d7a6ca9eba8752d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1771052
Auto-Submit: Erik Chen <erikchen@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690779}
parent fbd215e9
......@@ -227,6 +227,12 @@ RenderWidgetInputHandler::~RenderWidgetInputHandler() {}
viz::FrameSinkId RenderWidgetInputHandler::GetFrameSinkIdAtPoint(
const gfx::PointF& point,
gfx::PointF* local_point) {
// This method must only be called on a local root, which is guaranteed to
// have a WebWidget.
// TODO(https://crbug.com/995981): Eventually we should be able to remote this
// DCHECK, since RenderWidget's lifetime [and thus this instance's] will be
// synchronized with the WebWidget.
DCHECK(widget_->GetWebWidget());
gfx::PointF point_in_pixel(point);
if (widget_->compositor_deps()->IsUseZoomForDSFEnabled()) {
point_in_pixel = gfx::ConvertPointToPixel(
......@@ -264,6 +270,13 @@ viz::FrameSinkId RenderWidgetInputHandler::GetFrameSinkIdAtPoint(
WebInputEventResult RenderWidgetInputHandler::HandleTouchEvent(
const blink::WebCoalescedInputEvent& coalesced_event) {
// This method must only be called on non-frozen RenderWidget, which is
// guaranteed to have a WebWidget.
// TODO(https://crbug.com/995981): Eventually we should be able to remote this
// DCHECK, since RenderWidget's lifetime [and thus this instance's] will be
// synchronized with the WebWidget.
DCHECK(widget_->GetWebWidget());
const WebInputEvent& input_event = coalesced_event.Event();
if (input_event.GetType() == WebInputEvent::kTouchScrollStarted) {
......@@ -296,6 +309,13 @@ void RenderWidgetInputHandler::HandleInputEvent(
const blink::WebCoalescedInputEvent& coalesced_event,
const ui::LatencyInfo& latency_info,
HandledEventCallback callback) {
// This method must only be called on non-frozen RenderWidget, which is
// guaranteed to have a WebWidget.
// TODO(https://crbug.com/995981): Eventually we should be able to remote this
// DCHECK, since RenderWidget's lifetime [and thus this instance's] will be
// synchronized with the WebWidget.
DCHECK(widget_->GetWebWidget());
const WebInputEvent& input_event = coalesced_event.Event();
base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_,
true);
......@@ -583,6 +603,13 @@ void RenderWidgetInputHandler::HandleInjectedScrollGestures(
std::vector<InjectScrollGestureParams> injected_scroll_params,
const WebInputEvent& input_event,
const ui::LatencyInfo& original_latency_info) {
// This method must only be called on non-frozen RenderWidget, which is
// guaranteed to have a WebWidget.
// TODO(https://crbug.com/995981): Eventually we should be able to remote this
// DCHECK, since RenderWidget's lifetime [and thus this instance's] will be
// synchronized with the WebWidget.
DCHECK(widget_->GetWebWidget());
DCHECK(injected_scroll_params.size());
base::TimeTicks original_timestamp;
......
......@@ -722,12 +722,6 @@ void RenderWidget::PrepareForClose() {
void RenderWidget::OnSynchronizeVisualProperties(
const VisualProperties& original_params) {
// TODO:(https://crbug.com/995981): If there is no WebWidget, then the
// RenderWidget should also be destroyed, and this conditional should not be
// necessary.
if (!GetWebWidget())
return;
TRACE_EVENT0("renderer", "RenderWidget::OnSynchronizeVisualProperties");
VisualProperties params = original_params;
......@@ -1135,6 +1129,11 @@ void RenderWidget::RequestNewLayerTreeFrameSink(
void RenderWidget::DoRequestNewLayerTreeFrameSink(
LayerTreeFrameSinkCallback callback) {
// TODO:(https://crbug.com/995981): If there is no WebWidget, then the
// RenderWidget should also be destroyed, and this DCHECK should not be
// necessary.
DCHECK(GetWebWidget());
// TODO(jonross): have this generated by the LayerTreeFrameSink itself, which
// would then handle binding.
mojom::RenderFrameMetadataObserverPtr ptr;
......@@ -1572,6 +1571,10 @@ void RenderWidget::ResizeWebWidget() {
browser_controls_shrink_blink_size_);
return;
}
// TODO:(https://crbug.com/995981): If there is no WebWidget, then the
// RenderWidget should also be destroyed, and this DCHECK should not be
// necessary.
DCHECK(GetWebWidget());
GetWebWidget()->Resize(size);
}
......@@ -2564,6 +2567,15 @@ void RenderWidget::SetHidden(bool hidden) {
}
void RenderWidget::SetIsFullscreen(bool fullscreen) {
// TODO:(https://crbug.com/995981): If there is no WebWidget, then the
// RenderWidget should also be destroyed, and this conditional should not be
// necessary.
// We intentionally avoid setting internal state so that the next time visual
// properties are synchronized, state will be correctly propagated to the
// WebWidget.
if (!GetWebWidget())
return;
if (fullscreen == is_fullscreen_granted_)
return;
is_fullscreen_granted_ = fullscreen;
......
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