Tidy up null checking against WebContents
WebContentsUserData-backed objects requires its WebContents instance from
CVC be non-null, which causes numerous null checking statments. This CL
examines callsites to the methods that contains accesses to those
objects, adds null-checking statements if missing, and removes it
if redundant.
Some observations the changes are based on:
- private native method doesn't need null check; WebContents is
certainly valid at that point.
- CVC.destroy() itself or calls from it (before it nulls out WebContents)
doesn't need null check since WebContent is valid up to that point.
Added null check:
... since clusterfuzz results warn that these need it:
- setTouchScrollInProgress
- destroyPastePopup
... by moving it over from the 2 callsites:
- updateTextSelectionUI (onAttachedToWindow, onDetachedFromWindow)
Removed null check as callsites already have null checking/assert,
or assure WebContents is not null:
- hidePopupsAndClearSelection (WebContentObserver.resetPopupsAndInput,
onFocusChanged, showSelectPopup)
- hidePopupsAndPreserveSelection (destroy, onHide, updateTextSelectionUI,
onFocusChanged, onRotationChanged)
- hidePopups (above 2)
- onAttachedToWindow, onDetachedFromWindow: moved to updateTextSelectionUI
- onRotationChanged: consolidated null checks
Inlined one-liner restoreSelectionPopupsIfNecessary into callsites
to eliminate the concern on null check on it (much clearer when inlined).
Bug: 810179
Change-Id: I55aab2b1f7917a9af4522a1bcf8d3e7d9b172f2a
Reviewed-on: https://chromium-review.googlesource.com/907770
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by:
Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536016}
Showing
Please register or sign in to comment