[iOS] Update the MainContentUIState upon initialization.

The MainContentUIState used to broacast information to FullscreenModel
is instantiated when the BVC's view appears.  When presenting a view
controller, it receives the hidden/appearing signals and the default
state gets broadcasted.  This CL updates the
WebScrollViewMainContentUIForwarder to update the state immediately if
there is an active WebState.

Bug: 811729
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I823f01d3c86c0ec8dd0dc2b62b873071a0578b16
Reviewed-on: https://chromium-review.googlesource.com/917124
Commit-Queue: Kurt Horimoto <kkhorimoto@chromium.org>
Reviewed-by: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Cogan <marq@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#536515}(cherry picked from commit a88559f1ee9968255dfcdbd1d02303e2a42729eb)
Reviewed-on: https://chromium-review.googlesource.com/932483
Reviewed-by: Kurt Horimoto <kkhorimoto@chromium.org>
Cr-Commit-Position: refs/branch-heads/3325@{#553}
Cr-Branched-From: bc084a8b5afa3744a74927344e304c02ae54189f-refs/heads/master@{#530369}
diff --git a/ios/chrome/browser/ui/main_content/web_scroll_view_main_content_ui_forwarder.mm b/ios/chrome/browser/ui/main_content/web_scroll_view_main_content_ui_forwarder.mm
index 73561a2..01074de 100644
--- a/ios/chrome/browser/ui/main_content/web_scroll_view_main_content_ui_forwarder.mm
+++ b/ios/chrome/browser/ui/main_content/web_scroll_view_main_content_ui_forwarder.mm
@@ -19,6 +19,17 @@
 #error "This file requires ARC support."
 #endif
 
+namespace {
+// Uses the current values of |proxy|'s properties to update the
+// MainContentUIState via |updater|.
+void UpdateStateWithProxy(MainContentUIStateUpdater* updater,
+                          CRWWebViewScrollViewProxy* proxy) {
+  [updater scrollViewSizeDidChange:proxy.frame.size];
+  [updater scrollViewDidResetContentSize:proxy.contentSize];
+  [updater scrollViewDidResetContentInset:proxy.contentInset];
+}
+}
+
 @interface WebScrollViewMainContentUIForwarder ()<
     CRWWebStateObserver,
     CRWWebViewScrollViewProxyObserver,
@@ -36,6 +47,7 @@
 @property(nonatomic, assign) web::WebState* webState;
 // The scroll view proxy whose scroll events are forwarded to |updater|.
 @property(nonatomic, readonly, strong) CRWWebViewScrollViewProxy* proxy;
+
 @end
 
 @implementation WebScrollViewMainContentUIForwarder
@@ -60,6 +72,7 @@
       _webState->AddObserver(_webStateBridge.get());
       _proxy = activeWebState->GetWebViewProxy().scrollViewProxy;
       [_proxy addObserver:self];
+      UpdateStateWithProxy(_updater, _proxy);
     }
   }
   return self;
@@ -93,6 +106,7 @@
   [_proxy removeObserver:self];
   _proxy = proxy;
   [_proxy addObserver:self];
+  UpdateStateWithProxy(_updater, _proxy);
 }
 
 #pragma mark Public