Skip to content

Commit 9804f04

Browse files
committed
Xml Doc - Add more comments and fixes
1 parent 5409581 commit 9804f04

File tree

10 files changed

+113
-66
lines changed

10 files changed

+113
-66
lines changed

CefSharp.Core/Cef.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ namespace CefSharp
156156
{
157157
// NOTE: Can only initialize Cef once, to make this explicitly clear throw exception on subsiquent attempts
158158
throw gcnew Exception("CEF can only be initialized once per process. This is a limitation of the underlying " +
159-
"CEF/Chromium framework. You can change many (not all) settings at runtime through RequestContext.SetPreference. " +
160-
"See https://github.com/cefsharp/CefSharp/wiki/General-Usage#request-context-browser-isolation " +
161-
"Use Cef.IsInitialized to guard against this exception. If you are seeing this unexpectedly then you are likely " +
162-
"calling Cef.Initialize after you've created an instance of ChromiumWebBrowser, it must be before the first instance is created.");
159+
"CEF/Chromium framework. You can change many (not all) settings at runtime through RequestContext.SetPreference. " +
160+
"See https://github.com/cefsharp/CefSharp/wiki/General-Usage#request-context-browser-isolation " +
161+
"Use Cef.IsInitialized to guard against this exception. If you are seeing this unexpectedly then you are likely " +
162+
"calling Cef.Initialize after you've created an instance of ChromiumWebBrowser, it must be before the first instance is created.");
163163
}
164164

165165
if (cefSettings->BrowserSubprocessPath == nullptr)
@@ -277,6 +277,7 @@ namespace CefSharp
277277
/// <param name="allowTargetSubdomains">If set to true would allow a blah.example.com if the
278278
/// <paramref name="targetDomain"/> was set to example.com
279279
/// </param>
280+
/// <returns>Returns false if is invalid or the whitelist cannot be accessed.</returns>
280281
/// <remarks>
281282
/// The same-origin policy restricts how scripts hosted from different origins
282283
/// (scheme + domain + port) can communicate. By default, scripts can only access
@@ -361,6 +362,7 @@ namespace CefSharp
361362
/// <summary>
362363
/// Returns the global cookie manager.
363364
/// </summary>
365+
/// <returns>A the global cookie manager</returns>
364366
static ICookieManager^ GetGlobalCookieManager()
365367
{
366368
auto cookieManager = CefCookieManager::GetGlobalManager(NULL);
@@ -379,6 +381,7 @@ namespace CefSharp
379381
/// wish to only block cookies sent via the network use the IRequestHandler
380382
/// CanGetCookies and CanSetCookie methods instead.
381383
/// </summary>
384+
/// <returns>A blocking cookie manager</returns>
382385
static ICookieManager^ GetBlockingCookieManager()
383386
{
384387
auto cookieManager = CefCookieManager::GetBlockingManager();
@@ -408,9 +411,9 @@ namespace CefSharp
408411
if (_initializedThreadId != Thread::CurrentThread->ManagedThreadId)
409412
{
410413
throw gcnew Exception("Cef.Shutdown must be called on the same thread that Cef.Initialize was called - typically your UI thread." +
411-
"If you called Cef.Initialize on a Thread other than the UI thread then you will need to call Cef.Shutdown on the same thread." +
412-
"Cef.Initialize was called on ManagedThreadId: " + _initializedThreadId + "where Cef.Shutdown is being called on" +
413-
"ManagedThreadId:" + Thread::CurrentThread->ManagedThreadId);
414+
"If you called Cef.Initialize on a Thread other than the UI thread then you will need to call Cef.Shutdown on the same thread." +
415+
"Cef.Initialize was called on ManagedThreadId: " + _initializedThreadId + "where Cef.Shutdown is being called on" +
416+
"ManagedThreadId:" + Thread::CurrentThread->ManagedThreadId);
414417
}
415418

416419
UIThreadTaskFactory = nullptr;

CefSharp.WinForms/ChromiumWebBrowser.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,9 @@ public void RegisterAsyncJsObject(string name, object objectToBind, BindingOptio
582582
objectRepository.Register(name, objectToBind, true, options);
583583
}
584584

585+
/// <summary>
586+
/// The javascript object repository, one repository per ChromiumWebBrowser instance.
587+
/// </summary>
585588
public IJavascriptObjectRepository JavascriptObjectRepository
586589
{
587590
get { return managedCefBrowserAdapter == null ? null : managedCefBrowserAdapter.JavascriptObjectRepository; }

CefSharp.WinForms/ChromiumWebBrowserDesigner.cs

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,57 +3,65 @@
33
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
44

55
using System.Collections;
6-
using System.ComponentModel;
76
using System.Drawing;
8-
using System.Reflection;
9-
using System.Resources;
107
using System.Windows.Forms.Design;
118

129
namespace CefSharp.WinForms
1310
{
14-
public class ChromiumWebBrowserDesigner : ControlDesigner
15-
{
16-
protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
17-
{
18-
//NOTE: Removed until a better image can be found, add image as Embedded Resource and update name below
19-
//var assembly = Assembly.GetAssembly(typeof(ChromiumWebBrowserDesigner));
20-
21-
//using (var logo = assembly.GetManifestResourceStream("CefSharp.WinForms.CefSharpLogo.png"))
22-
//using (var img = Image.FromStream(logo))
23-
//{
24-
// pe.Graphics.DrawImage(img, 0, 0);
25-
//}
26-
27-
using(var font = new Font("Arial", 16))
28-
using (var stringFormat = new StringFormat
29-
{
30-
// Create a StringFormat object with the each line of text, and the block
31-
// of text centered on the page.
32-
Alignment = StringAlignment.Center,
33-
LineAlignment = StringAlignment.Center
34-
})
35-
{
36-
pe.Graphics.DrawString("ChromiumWebBrowser", font, Brushes.Black, pe.ClipRectangle, stringFormat);
37-
}
38-
39-
base.OnPaintAdornments(pe);
40-
}
41-
42-
protected override void PreFilterProperties(IDictionary properties)
43-
{
44-
//Remove some of the default properties from the designer
45-
//they don't have much meaning for the browser
46-
//Probably more that can be removed/tweaked
47-
properties.Remove("BackgroundImage");
48-
properties.Remove("BackgroundImageLayout");
49-
properties.Remove("Text");
50-
51-
properties.Remove("Font");
52-
properties.Remove("ForeColor");
53-
properties.Remove("BackColor");
54-
properties.Remove("RightToLeft");
55-
56-
base.PreFilterProperties(properties);
57-
}
58-
}
11+
/// <summary>
12+
/// ChromiumWebBrowser Control Designer
13+
/// </summary>
14+
public class ChromiumWebBrowserDesigner : ControlDesigner
15+
{
16+
/// <summary>
17+
/// Receives a call when the control that the designer is managing has painted its surface so the designer can paint any additional adornments on top of the control.
18+
/// </summary>
19+
/// <param name="pe">args</param>
20+
protected override void OnPaintAdornments(System.Windows.Forms.PaintEventArgs pe)
21+
{
22+
//NOTE: Removed until a better image can be found, add image as Embedded Resource and update name below
23+
//var assembly = Assembly.GetAssembly(typeof(ChromiumWebBrowserDesigner));
24+
25+
//using (var logo = assembly.GetManifestResourceStream("CefSharp.WinForms.CefSharpLogo.png"))
26+
//using (var img = Image.FromStream(logo))
27+
//{
28+
// pe.Graphics.DrawImage(img, 0, 0);
29+
//}
30+
31+
using(var font = new Font("Arial", 16))
32+
using (var stringFormat = new StringFormat
33+
{
34+
// Create a StringFormat object with the each line of text, and the block
35+
// of text centered on the page.
36+
Alignment = StringAlignment.Center,
37+
LineAlignment = StringAlignment.Center
38+
})
39+
{
40+
pe.Graphics.DrawString("ChromiumWebBrowser", font, Brushes.Black, pe.ClipRectangle, stringFormat);
41+
}
42+
43+
base.OnPaintAdornments(pe);
44+
}
45+
46+
/// <summary>
47+
/// Adjusts the set of properties the component exposes through a TypeDescriptor.
48+
/// </summary>
49+
/// <param name="properties">properties</param>
50+
protected override void PreFilterProperties(IDictionary properties)
51+
{
52+
//Remove some of the default properties from the designer
53+
//they don't have much meaning for the browser
54+
//Probably more that can be removed/tweaked
55+
properties.Remove("BackgroundImage");
56+
properties.Remove("BackgroundImageLayout");
57+
properties.Remove("Text");
58+
59+
properties.Remove("Font");
60+
properties.Remove("ForeColor");
61+
properties.Remove("BackColor");
62+
properties.Remove("RightToLeft");
63+
64+
base.PreFilterProperties(properties);
65+
}
66+
}
5967
}

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,10 @@ void IRenderWebBrowser.UpdateDragCursor(DragOperationsMask operation)
756756
UpdateDragCursor(operation);
757757
}
758758

759+
/// <summary>
760+
/// Called when the web view wants to update the mouse cursor during a drag &amp; drop operation.
761+
/// </summary>
762+
/// <param name="operation">describes the allowed operation (none, move, copy, link). </param>
759763
protected virtual void UpdateDragCursor(DragOperationsMask operation)
760764
{
761765
//TODO: Someone should implement this
@@ -780,7 +784,7 @@ void IRenderWebBrowser.OnPaint(PaintElementType type, Rect dirtyRect, IntPtr buf
780784
/// override this method or implement your own <see cref="IRenderHandler"/> and assign to <see cref="RenderHandler"/>
781785
/// Called on the CEF UI Thread
782786
/// </summary>
783-
/// <param name="type">indicates whether the element is the view or the popup widget.</param>
787+
/// <param name="isPopup">indicates whether the element is the view or the popup widget.</param>
784788
/// <param name="dirtyRect">contains the set of rectangles in pixel coordinates that need to be repainted</param>
785789
/// <param name="buffer">The bitmap will be will be width * height *4 bytes in size and represents a BGRA image with an upper-left origin</param>
786790
/// <param name="width">width</param>
@@ -808,10 +812,7 @@ protected virtual void OnPaint(bool isPopup, Rect dirtyRect, IntPtr buffer, int
808812
/// <summary>
809813
/// Sets the popup size and position.
810814
/// </summary>
811-
/// <param name="width">The width.</param>
812-
/// <param name="height">The height.</param>
813-
/// <param name="x">The x.</param>
814-
/// <param name="y">The y.</param>
815+
/// <param name="rect">The popup rectangle (size and position).</param>
815816
void IRenderWebBrowser.OnPopupSize(Rect rect)
816817
{
817818
UiThreadRunAsync(() => SetPopupSizeAndPositionImpl(rect));
@@ -831,6 +832,7 @@ void IRenderWebBrowser.OnPopupShow(bool isOpen)
831832
/// </summary>
832833
/// <param name="handle">The handle.</param>
833834
/// <param name="type">The type.</param>
835+
/// <param name="customCursorInfo">custom cursor information</param>
834836
void IRenderWebBrowser.OnCursorChange(IntPtr handle, CursorType type, CursorInfo customCursorInfo)
835837
{
836838
//Custom cursors are handled differently, for now keep standard ones executing
@@ -860,6 +862,11 @@ void IRenderWebBrowser.OnImeCompositionRangeChanged(Range selectedRange, Rect[]
860862
OnImeCompositionRangeChanged(selectedRange, characterBounds);
861863
}
862864

865+
/// <summary>
866+
/// Called when the IME composition range has changed.
867+
/// </summary>
868+
/// <param name="selectedRange">is the range of characters that have been selected</param>
869+
/// <param name="characterBounds">is the bounds of each character in view coordinates.</param>
863870
protected virtual void OnImeCompositionRangeChanged(Range selectedRange, Rect[] characterBounds)
864871
{
865872
//TODO: Implement this
@@ -1908,6 +1915,7 @@ private Popup CreatePopup()
19081915
return newPopup;
19091916
}
19101917

1918+
/// <summary>
19111919
/// Converts a .NET Drag event to a CefSharp MouseEvent
19121920
/// </summary>
19131921
/// <param name="e">The <see cref="DragEventArgs"/> instance containing the event data.</param>
@@ -1922,10 +1930,7 @@ private MouseEvent GetMouseEvent(DragEventArgs e)
19221930
/// <summary>
19231931
/// Sets the popup size and position implementation.
19241932
/// </summary>
1925-
/// <param name="width">The width.</param>
1926-
/// <param name="height">The height.</param>
1927-
/// <param name="x">The x.</param>
1928-
/// <param name="y">The y.</param>
1933+
/// <param name="rect">The popup rectangle (size and position).</param>
19291934
private void SetPopupSizeAndPositionImpl(Rect rect)
19301935
{
19311936
popup.Width = rect.Width ;
@@ -2360,6 +2365,9 @@ public void RegisterAsyncJsObject(string name, object objectToBind, BindingOptio
23602365
objectRepository.Register(name, objectToBind, true, options);
23612366
}
23622367

2368+
/// <summary>
2369+
/// The javascript object repository, one repository per ChromiumWebBrowser instance.
2370+
/// </summary>
23632371
public IJavascriptObjectRepository JavascriptObjectRepository
23642372
{
23652373
get { return managedCefBrowserAdapter?.JavascriptObjectRepository; }

CefSharp.Wpf/IRenderHandler.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@ namespace CefSharp.Wpf
1515
/// </summary>
1616
public interface IRenderHandler : IDisposable
1717
{
18+
/// <summary>
19+
/// Called when an element should be painted. (Invoked from CefRenderHandler.OnPaint)
20+
/// </summary>
21+
/// <param name="isPopup">indicates whether the element is the view or the popup widget.</param>
22+
/// <param name="dirtyRect">contains the set of rectangles in pixel coordinates that need to be repainted</param>
23+
/// <param name="buffer">The bitmap will be will be width * height *4 bytes in size and represents a BGRA image with an upper-left origin</param>
24+
/// <param name="width">width</param>
25+
/// <param name="height">height</param>
26+
/// <param name="image">image used as parent for rendered bitmap</param>
1827
void OnPaint(bool isPopup, Rect dirtyRect, IntPtr buffer, int width, int height, Image image);
1928
}
2029
}

CefSharp.Wpf/PaintEventArgs.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ public class PaintEventArgs : EventArgs
4646
/// <summary>
4747
/// Initializes a new instance of the <see cref="PaintEventArgs"/> class.
4848
/// </summary>
49-
/// <param name="bitmapInfo">The bitmap information.</param>
49+
/// <param name="isPopup">is popup</param>
50+
/// <param name="dirtyRect">direct rectangle</param>
51+
/// <param name="buffer">buffer</param>
52+
/// <param name="width">width</param>
53+
/// <param name="height">height</param>
5054
public PaintEventArgs(bool isPopup, Rect dirtyRect, IntPtr buffer, int width, int height)
5155
{
5256
IsPopup = isPopup;

CefSharp.Wpf/Rendering/Experimental/IncreaseBufferInteropRenderHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public IncreaseBufferInteropRenderHandler(DispatcherPriority dispatcherPriority
5252
this.dispatcherPriority = dispatcherPriority;
5353
}
5454

55+
/// <summary>
56+
/// Dispose
57+
/// </summary>
5558
public void Dispose()
5659
{
5760
ReleaseMemoryMappedView(ref popupMemoryMappedFile, ref popupMemoryMappedViewAccessor);

CefSharp.Wpf/Rendering/InteropBitmapRenderHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public InteropBitmapRenderHandler(DispatcherPriority dispatcherPriority = Dispat
5252
this.dispatcherPriority = dispatcherPriority;
5353
}
5454

55+
/// <summary>
56+
/// Dispose
57+
/// </summary>
5558
public void Dispose()
5659
{
5760
ReleaseMemoryMappedView(ref popupMemoryMappedFile, ref popupMemoryMappedViewAccessor);

CefSharp.Wpf/Rendering/WritableBitmapRenderHandler.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public WritableBitmapRenderHandler(double dpiX, double dpiY, bool invalidateDirt
6161
this.dispatcherPriority = dispatcherPriority;
6262
}
6363

64+
/// <summary>
65+
/// Dispose
66+
/// </summary>
6467
public void Dispose()
6568
{
6669
ReleaseMemoryMappedView(ref popupMemoryMappedFile, ref popupMemoryMappedViewAccessor);

CefSharp.Wpf/WM.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
namespace CefSharp.Wpf
22
{
3-
// Gratiously based on http://www.pinvoke.net/default.aspx/Enums/WindowsMessages.html
3+
/// <summary>
4+
/// Windows Message Enums
5+
/// Gratiosly based on http://www.pinvoke.net/default.aspx/Enums/WindowsMessages.html
6+
/// </summary>
47
public enum WM : uint
58
{
69
/// <summary>

0 commit comments

Comments
 (0)