Clean cherry-pick: Fix a crash reported by monkey tests.

BUG:17316153

-----------------------------------------------------------

Fix a crash reported by monkey tests.

BUG=405504

Review URL: https://codereview.chromium.org/501473002

Change-Id: I749a1740cd602f586895906977e1eaa006590f17
Cr-Commit-Position: refs/heads/master@{#292359}
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 4b02e99..12c3d07 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -457,6 +457,11 @@
             @SuppressWarnings("deprecation")  // AbsoluteLayout
             public void setAnchorViewPosition(
                     View view, float x, float y, float width, float height) {
+                if (view.getParent() == null) {
+                    // Ignore. setAnchorViewPosition has been called after the anchor view has
+                    // already been released.
+                    return;
+                }
                 assert view.getParent() == mContainerViewAtCreation;
 
                 float scale = (float) DeviceDisplayInfo.create(mContext).getDIPScale();