Skip to content

Commit

Permalink
Use GhostDoc to generate bulk xml documentation - it's not perfect at…
Browse files Browse the repository at this point in the history
… least a lot of the interface doco has been copied into the

ChromiumWebBrowser instance classes
  • Loading branch information
amaitland committed Jun 15, 2016
1 parent 46b6c31 commit afe758e
Show file tree
Hide file tree
Showing 19 changed files with 1,645 additions and 72 deletions.
17 changes: 17 additions & 0 deletions CefSharp.OffScreen/BitmapFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,32 @@

namespace CefSharp.OffScreen
{
/// <summary>
/// BitmapFactory.
/// </summary>
/// <seealso cref="CefSharp.IBitmapFactory" />
public class BitmapFactory : IBitmapFactory
{
/// <summary>
/// The bitmap lock
/// </summary>
private readonly object bitmapLock;

/// <summary>
/// Initializes a new instance of the <see cref="BitmapFactory"/> class.
/// </summary>
/// <param name="lockObject">The lock object.</param>
public BitmapFactory(object lockObject)
{
bitmapLock = lockObject;
}

/// <summary>
/// Create an instance of BitmapInfo based on the params
/// </summary>
/// <param name="isPopup">create bitmap info for a popup (typically just a bool flag used internally)</param>
/// <param name="dpiScale">DPI scale</param>
/// <returns>newly created BitmapInfo</returns>
BitmapInfo IBitmapFactory.CreateBitmap(bool isPopup, double dpiScale)
{
//The bitmap buffer is 32 BPP
Expand Down
312 changes: 296 additions & 16 deletions CefSharp.OffScreen/ChromiumWebBrowser.cs

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions CefSharp.OffScreen/GdiBitmapInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,51 @@

namespace CefSharp.OffScreen
{
/// <summary>
/// Uses GdiBitmap to render the backbuffer.
/// </summary>
/// <seealso cref="CefSharp.Internals.BitmapInfo" />
public class GdiBitmapInfo : BitmapInfo
{
/// <summary>
/// The bitmap
/// </summary>
private Bitmap bitmap;

/// <summary>
/// The create new bitmap
/// </summary>
private bool createNewBitmap;

/// <summary>
/// Initializes a new instance of the <see cref="GdiBitmapInfo"/> class.
/// </summary>
public GdiBitmapInfo()
{
BytesPerPixel = 4;
}

/// <summary>
/// Gets a value indicating whether [create new bitmap].
/// </summary>
/// <value><c>true</c> if [create new bitmap]; otherwise, <c>false</c>.</value>
public override bool CreateNewBitmap
{
get { return createNewBitmap; }
}

/// <summary>
/// Clears the bitmap.
/// </summary>
public override void ClearBitmap()
{
createNewBitmap = true;
}

/// <summary>
/// Creates the bitmap.
/// </summary>
/// <returns>Bitmap.</returns>
public virtual Bitmap CreateBitmap()
{
if(BackBufferHandle == IntPtr.Zero)
Expand Down
286 changes: 275 additions & 11 deletions CefSharp.WinForms/ChromiumWebBrowser.cs

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions CefSharp.WinForms/IWinFormsWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@

namespace CefSharp.WinForms
{
// Should rightfully live in the CefSharp.WinForms project, but the problem is that it's being used from CefSharp.Core
// so the dependency would go the wrong way... Has to be here for the time being.
/// <summary>
/// WinForms specific implementation, has events the
/// <see cref="ChromiumWebBrowser" /> implementation exposes.
/// </summary>
/// </summary>
/// <seealso cref="CefSharp.IWebBrowser" />
public interface IWinFormsWebBrowser : IWebBrowser
{
/// <summary>
/// Occurs when the browser title changed.
/// </summary>
event EventHandler<TitleChangedEventArgs> TitleChanged;
/// <summary>
/// Occurs when the browser address changed.
/// </summary>
event EventHandler<AddressChangedEventArgs> AddressChanged;
}
}
13 changes: 13 additions & 0 deletions CefSharp.WinForms/Internals/ControlExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace CefSharp.WinForms.Internals
{
/// <summary>
/// ControlExtensions.
/// </summary>
public static class ControlExtensions
{
/// <summary>
Expand All @@ -26,6 +29,11 @@ public static void InvokeOnUiThreadIfRequired(this Control control, Action actio
}
}

/// <summary>
/// Activates the specified control.
/// </summary>
/// <param name="control">The control.</param>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
public static bool Activate(this Control control)
{
// Notify WinForms world that inner browser window got focus. This will trigger Leave event to previous focused control
Expand Down Expand Up @@ -56,6 +64,11 @@ public static bool IsActiveControl(this Control control)
return Object.ReferenceEquals(control, activeControl);
}

/// <summary>
/// Selects the next control.
/// </summary>
/// <param name="control">The control.</param>
/// <param name="next">if set to <c>true</c> [next].</param>
public static void SelectNextControl(this Control control, bool next)
{
var containerControl = control.GetContainerControl();
Expand Down
34 changes: 29 additions & 5 deletions CefSharp.WinForms/Internals/DefaultFocusHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,33 @@
using System.Windows.Forms;
namespace CefSharp.WinForms.Internals
{
/// <summary>
/// Default implementation of <see cref="CefSharp.IFocusHandler" />
/// for the WinForms implementation
/// </summary>
/// <seealso cref="CefSharp.IFocusHandler" />
public class DefaultFocusHandler : IFocusHandler
{
/// <summary>
/// The browser
/// </summary>
private readonly ChromiumWebBrowser browser;

/// <summary>
/// Initializes a new instance of the <see cref="DefaultFocusHandler"/> class.
/// </summary>
/// <param name="browser">The browser.</param>
public DefaultFocusHandler(ChromiumWebBrowser browser)
{
this.browser = browser;
}

/// <remarks>
/// Try to avoid needing to override this logic in a subclass. The implementation in
/// DefaultFocusHandler relies on very detailed behavior of how WinForms and
/// Windows interact during window activation.
/// </remarks>
/// <summary>
/// Called when the browser component has received focus.
/// </summary>
/// <remarks>Try to avoid needing to override this logic in a subclass. The implementation in
/// DefaultFocusHandler relies on very detailed behavior of how WinForms and
/// Windows interact during window activation.</remarks>
public virtual void OnGotFocus()
{
// During application activation, CEF receives a WM_SETFOCUS
Expand Down Expand Up @@ -73,12 +86,23 @@ public virtual void OnGotFocus()
}
}

/// <summary>
/// Called when the browser component is requesting focus.
/// </summary>
/// <param name="source">Indicates where the focus request is originating from.</param>
/// <returns>Return false to allow the focus to be set or true to cancel setting the focus.</returns>
public virtual bool OnSetFocus(CefFocusSource source)
{
// Do not let the browser take focus when a Load method has been called
return source == CefFocusSource.FocusSourceNavigation;
}

/// <summary>
/// Called when the browser component is about to lose focus.
/// For instance, if focus was on the last HTML element and the user pressed the TAB key.
/// </summary>
/// <param name="next">Will be true if the browser is giving focus to the next component
/// and false if the browser is giving focus to the previous component.</param>
public virtual void OnTakeFocus(bool next)
{
// NOTE: OnTakeFocus means leaving focus / not taking focus
Expand Down
18 changes: 17 additions & 1 deletion CefSharp.WinForms/Internals/NativeMethods.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
using System;
// Copyright © 2010-2016 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CefSharp.WinForms.Internals
{
/// <summary>
/// Class NativeMethods.
/// </summary>
internal static class NativeMethods
{
/// <summary>
/// The w m_ move
/// </summary>
public const int WM_MOVE = 0x3;
/// <summary>
/// The w m_ moving
/// </summary>
public const int WM_MOVING = 0x216;
/// <summary>
/// The w m_ activate
/// </summary>
public const int WM_ACTIVATE = 0x6;
}
}
50 changes: 48 additions & 2 deletions CefSharp.WinForms/Internals/ParentFormMessageInterceptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@

namespace CefSharp.WinForms.Internals
{
/// <summary>
/// ParentFormMessageInterceptor - hooks into the parent forms
/// message loop to incercept messages like WM_MOVE
/// </summary>
/// <seealso cref="System.Windows.Forms.NativeWindow" />
/// <seealso cref="System.IDisposable" />
internal class ParentFormMessageInterceptor : NativeWindow, IDisposable
{
/// <summary>
Expand All @@ -22,10 +28,22 @@ internal class ParentFormMessageInterceptor : NativeWindow, IDisposable
/// </summary>
private Rectangle movingRectangle;

/// <summary>
/// Gets or sets the browser.
/// </summary>
/// <value>The browser.</value>
private ChromiumWebBrowser Browser { get; set; }

/// <summary>
/// Gets or sets the parent form.
/// </summary>
/// <value>The parent form.</value>
private Form ParentForm { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ParentFormMessageInterceptor"/> class.
/// </summary>
/// <param name="browser">The browser.</param>
public ParentFormMessageInterceptor(ChromiumWebBrowser browser)
{
Browser = browser;
Expand All @@ -36,7 +54,7 @@ public ParentFormMessageInterceptor(ChromiumWebBrowser browser)
}

/// <summary>
/// Call to force refinding of the parent Form.
/// Call to force refinding of the parent Form.
/// (i.e. top level window that owns the ChromiumWebBrowserControl)
/// </summary>
public void RefindParentForm()
Expand All @@ -48,7 +66,7 @@ public void RefindParentForm()
/// Adjust the form to listen to if the ChromiumWebBrowserControl's parent changes.
/// </summary>
/// <param name="sender">The ChromiumWebBrowser whose parent has changed.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
private void ParentParentChanged(object sender, EventArgs e)
{
var control = (Control)sender;
Expand Down Expand Up @@ -81,16 +99,30 @@ private void ParentParentChanged(object sender, EventArgs e)
}
}

/// <summary>
/// Handles the <see cref="E:HandleCreated" /> event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnHandleCreated(object sender, EventArgs e)
{
AssignHandle(((Form)sender).Handle);
}

/// <summary>
/// Handles the <see cref="E:HandleDestroyed" /> event.
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnHandleDestroyed(object sender, EventArgs e)
{
ReleaseHandle();
}

/// <summary>
/// Invokes the default window procedure associated with this window.
/// </summary>
/// <param name="m">A <see cref="T:System.Windows.Forms.Message" /> that is associated with the current Windows message.</param>
protected override void WndProc(ref Message m)
{
var isMovingMessage = false;
Expand Down Expand Up @@ -199,6 +231,9 @@ protected override void WndProc(ref Message m)
DefWndProc(ref m);
}

/// <summary>
/// Called when [moving].
/// </summary>
protected virtual void OnMoving()
{
isMoving = true;
Expand All @@ -211,11 +246,18 @@ protected virtual void OnMoving()
isMoving = false;
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
Dispose(true);
}

/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing)
{
if (disposing)
Expand Down Expand Up @@ -246,6 +288,10 @@ protected virtual void Dispose(bool disposing)
}
}

/// <summary>
/// When overridden in a derived class, manages an unhandled thread exception.
/// </summary>
/// <param name="e">An <see cref="T:System.Exception" /> that specifies the unhandled thread exception.</param>
protected override void OnThreadException(Exception e)
{
// TODO: Do something more interesting here, logging, whatever, something.
Expand Down
Loading

0 comments on commit afe758e

Please sign in to comment.