Clarify EmulationHandler early outs, null checks, and frame relationship
The EmulationHandler only enables touch or device emulation on the main frame. Currently the touch handler is explicit about this, which was added a few months after the check for being a local root. That change should obsolete the local root check (main frame is a subset of local root frames), though both remain in the code. Remove the local root comparison. The device emulation path still only checks for local root, but could be changed to main frame also for more clarity. The GetWebContents() method returns null only if the host_ is null, so instead of checking both of these for null, only call GetWebContents() when |host_| is not null, and change methods to check for |host_| in places that they checked for GetWebContents(). The GetRenderWidgetHost() on RenderFrameHostImpl never returns null, as per its comment: // Returns the RenderWidgetHostImpl attached to this frame or the nearest // ancestor frame, which could potentially be the root. For most input // and rendering related purposes, GetView() should be preferred and // RenderWidgetHostViewBase methods used. GetRenderWidgetHost() will not // return a nullptr, whereas GetView() potentially will (for instance, // after a renderer crash). // // This method crashes if this RenderFrameHostImpl does not own a // a RenderWidgetHost and nor does any of its ancestors. That would // typically mean that the frame has been detached from the frame tree. virtual RenderWidgetHostImpl* GetRenderWidgetHost(); R=yangguo@chromium.org Bug: 1006052 Change-Id: Ia43c2fb04de343f7c6e2c7cd1600a9bdc1a14908 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1815735 Auto-Submit: danakj <danakj@chromium.org> Commit-Queue: Yang Guo <yangguo@chromium.org> Reviewed-by:Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#698840}
Showing
Please register or sign in to comment