summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs
diff options
context:
space:
mode:
authorkingces95 <kingces95@users.noreply.github.com>2017-04-11 18:02:06 (GMT)
committerRui Marinho <me@ruimarinho.net>2017-04-11 18:02:06 (GMT)
commit093a4efa2da9cb681890158ca8ee9bb6f30b0a8c (patch)
treeccc17255876e40d2c845d7b2c62dfc930156729d /Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs
parent7458ca37330f424bf7fb1447580b0fa9c34c6db4 (diff)
downloadxamarin-forms-093a4efa2da9cb681890158ca8ee9bb6f30b0a8c.zip
xamarin-forms-093a4efa2da9cb681890158ca8ee9bb6f30b0a8c.tar.gz
xamarin-forms-093a4efa2da9cb681890158ca8ee9bb6f30b0a8c.tar.bz2
Implicit impl of controller ifaces (#807)
* Simplify ICtrl callsites * Rebase fix
Diffstat (limited to 'Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs24
1 files changed, 11 insertions, 13 deletions
diff --git a/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs b/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs
index 509c38f..98130ee 100644
--- a/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs
+++ b/Xamarin.Forms.Platform.MacOS/Renderers/WebViewRenderer.cs
@@ -13,8 +13,6 @@ namespace Xamarin.Forms.Platform.MacOS
WebNavigationEvent _lastBackForwardEvent;
WebNavigationEvent _lastEvent;
- IWebViewController ElementController => Element;
-
void IWebViewDelegate.LoadHtml(string html, string baseUrl)
{
if (html != null)
@@ -43,9 +41,9 @@ namespace Xamarin.Forms.Platform.MacOS
Control.OnFinishedLoading += OnNSWebViewFinishedLoad;
Control.OnFailedLoading += OnNSWebViewFailedLoadWithError;
- ElementController.EvalRequested += OnEvalRequested;
- ElementController.GoBackRequested += OnGoBackRequested;
- ElementController.GoForwardRequested += OnGoForwardRequested;
+ Element.EvalRequested += OnEvalRequested;
+ Element.GoBackRequested += OnGoBackRequested;
+ Element.GoForwardRequested += OnGoForwardRequested;
Layer.BackgroundColor = NSColor.Clear.CGColor;
}
@@ -69,9 +67,9 @@ namespace Xamarin.Forms.Platform.MacOS
_disposed = true;
Control.OnFinishedLoading -= OnNSWebViewFinishedLoad;
Control.OnFailedLoading -= OnNSWebViewFailedLoadWithError;
- ElementController.EvalRequested -= OnEvalRequested;
- ElementController.GoBackRequested -= OnGoBackRequested;
- ElementController.GoForwardRequested -= OnGoForwardRequested;
+ Element.EvalRequested -= OnEvalRequested;
+ Element.GoBackRequested -= OnGoBackRequested;
+ Element.GoForwardRequested -= OnGoForwardRequested;
}
base.Dispose(disposing);
}
@@ -90,8 +88,8 @@ namespace Xamarin.Forms.Platform.MacOS
{
if (Element == null)
return;
- ElementController.CanGoBack = Control.CanGoBack();
- ElementController.CanGoForward = Control.CanGoForward();
+ ((IWebViewController)Element).CanGoBack = Control.CanGoBack();
+ ((IWebViewController)Element).CanGoForward = Control.CanGoForward();
}
void OnEvalRequested(object sender, EvalRequested eventArg)
@@ -124,7 +122,7 @@ namespace Xamarin.Forms.Platform.MacOS
void OnNSWebViewFailedLoadWithError(object sender, WebKit.WebResourceErrorEventArgs e)
{
_lastEvent = _lastBackForwardEvent;
- ElementController?.SendNavigated(new WebNavigatedEventArgs(_lastEvent, new UrlWebViewSource { Url = Control.MainFrameUrl },
+ Element?.SendNavigated(new WebNavigatedEventArgs(_lastEvent, new UrlWebViewSource { Url = Control.MainFrameUrl },
Control.MainFrameUrl, WebNavigationResult.Failure));
UpdateCanGoBackForward();
@@ -136,11 +134,11 @@ namespace Xamarin.Forms.Platform.MacOS
return;
_ignoreSourceChanges = true;
- ElementController?.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource { Url = Control.MainFrameUrl });
+ Element?.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource { Url = Control.MainFrameUrl });
_ignoreSourceChanges = false;
_lastEvent = _lastBackForwardEvent;
- ElementController?.SendNavigated(new WebNavigatedEventArgs(_lastEvent, Element?.Source, Control.MainFrameUrl,
+ Element?.SendNavigated(new WebNavigatedEventArgs(_lastEvent, Element?.Source, Control.MainFrameUrl,
WebNavigationResult.Success));
UpdateCanGoBackForward();