protected override void OnLoad(EventArgs e)
{
Debug.Assert(!InvokeRequired);
base.OnLoad(e);
if(DesignMode)
{
this.BackColor=Color.DarkGray;
return;
}
_browser = new GeckoWebBrowser();
_browser.Parent = this;
_browser.Dock = DockStyle.Fill;
Controls.Add(_browser);
_browser.NoDefaultContextMenu = true;
_browser.ShowContextMenu += OnShowContextMenu;
_browser.Navigating += _browser_Navigating;
//NB: registering for domclicks seems to stop normal hyperlinking (which we don't
//necessarily need). When I comment this out, I get an error if the href had, for example,
//"bloom" for the protocol. We could probably install that as a protocol, rather than
//using the click to just get a target and go from there, if we wanted.
_browser.DomClick += OnBrowser_DomClick;
_browser.DomKeyPress += OnDomKeyPress;
_browserIsReadyToNavigate = true;
UpdateDisplay();
_browser.Navigated += CleanupAfterNavigation;//there's also a "document completed"
_browser.DocumentCompleted += new EventHandler<GeckoDocumentCompletedEventArgs>(_browser_DocumentCompleted);
_browser.ConsoleMessage += OnConsoleMessage;
//Developers can turn this on when you're tracking something, but unfortunately the number of false positives
//is extremely high. Even caught exceptions get reported here, e.g. libraries trying to figure out which
//browser they are running in intentionally test for things that aren't there, and those get reported.
//When we upgrate to Firefox 45, which has a totally different debugging system, we can see if maybe we
//can turn this back on. Meanwhile, running in a browser is a good way to see real errors.
//_browser.JavascriptError += OnJavascriptError;
// This makes any zooming zoom everything, not just enlarge text.
// May be obsolete, since I don't think we are using the sort of zooming it controls.
// Instead we implement zoom ourselves in a more controlled way using transform: scale
GeckoPreferences.User["browser.zoom.full"] = true;
// in firefox 14, at least, there was a bug such that if you have more than one lang on
// the page, all are check with English
// until we get past that, it's just annoying
GeckoPreferences.User["layout.spellcheckDefault"] = 0;
_browser.FrameEventsPropagateToMainWindow = true; // we want clicks in iframes to propagate all the way up to C#
RaiseGeckoReady();
}