Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions CefSharp.Wpf/ChromiumWebBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

using System.Text;
using CefSharp.Internals;
using CefSharp.Wpf.Rendering;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
Expand Down Expand Up @@ -409,7 +409,7 @@ public bool CanGoBack
get { return (bool)GetValue(CanGoBackProperty); }
}

public static DependencyProperty CanGoBackProperty = DependencyProperty.Register("CanGoBack", typeof (bool), typeof (ChromiumWebBrowser));
public static DependencyProperty CanGoBackProperty = DependencyProperty.Register("CanGoBack", typeof(bool), typeof(ChromiumWebBrowser));

#endregion

Expand All @@ -420,7 +420,7 @@ public bool CanGoForward
get { return (bool)GetValue(CanGoForwardProperty); }
}

public static DependencyProperty CanGoForwardProperty = DependencyProperty.Register("CanGoForward", typeof (bool), typeof (ChromiumWebBrowser));
public static DependencyProperty CanGoForwardProperty = DependencyProperty.Register("CanGoForward", typeof(bool), typeof(ChromiumWebBrowser));

#endregion

Expand All @@ -431,7 +431,7 @@ public bool CanReload
get { return (bool)GetValue(CanReloadProperty); }
}

public static DependencyProperty CanReloadProperty = DependencyProperty.Register("CanReload", typeof (bool), typeof (ChromiumWebBrowser));
public static DependencyProperty CanReloadProperty = DependencyProperty.Register("CanReload", typeof(bool), typeof(ChromiumWebBrowser));

#endregion

Expand Down Expand Up @@ -510,7 +510,6 @@ private static void OnIsBrowserInitializedChanged(DependencyObject d, Dependency

protected virtual void OnIsBrowserInitializedChanged(bool oldValue, bool newValue)
{

}

#endregion IsInitialized dependency property
Expand All @@ -524,7 +523,21 @@ public string Title
}

public static readonly DependencyProperty TitleProperty =
DependencyProperty.Register("Title", typeof(string), typeof(ChromiumWebBrowser), new PropertyMetadata(defaultValue: null));
DependencyProperty.Register("Title", typeof(string), typeof(ChromiumWebBrowser), new PropertyMetadata(null, OnTitleChanged));

public event DependencyPropertyChangedEventHandler TitleChanged;

private static void OnTitleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var owner = (ChromiumWebBrowser)d;

var handlers = owner.TitleChanged;

if (handlers != null)
{
handlers(owner, e);
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the essence of the PR.


#endregion Title dependency property

Expand Down Expand Up @@ -768,7 +781,7 @@ private static string GetLink(IDataObject data)
return unicodeUrl;
}
}

// Try ASCII
if (data.GetDataPresent(asciiUrlDataFormatName))
{
Expand Down Expand Up @@ -927,7 +940,7 @@ private Popup CreatePopup()

private IntPtr SourceHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled)
{
if(handled)
if (handled)
{
return IntPtr.Zero;
}
Expand All @@ -941,7 +954,6 @@ private IntPtr SourceHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam
case WM.KEYUP:
case WM.CHAR:
case WM.IME_CHAR:
{
if (!IsKeyboardFocused)
{
break;
Expand All @@ -956,9 +968,8 @@ private IntPtr SourceHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam
}

handled = managedCefBrowserAdapter.SendKeyEvent(message, wParam.ToInt32(), lParam);

break;
}
}

return IntPtr.Zero;
Expand Down Expand Up @@ -1018,7 +1029,7 @@ private static CefEventFlags GetModifiers(MouseEventArgs e)

if (Keyboard.IsKeyDown(Key.LeftAlt))
{
modifiers |= CefEventFlags.AltDown| CefEventFlags.IsLeft;
modifiers |= CefEventFlags.AltDown | CefEventFlags.IsLeft;
}

if (Keyboard.IsKeyDown(Key.RightAlt))
Expand Down Expand Up @@ -1135,7 +1146,7 @@ private void OnPreviewKey(KeyEventArgs e)
// Hooking the Tab key like this makes the tab focusing in essence work like
// KeyboardNavigation.TabNavigation="Cycle"; you will never be able to Tab out of the web browser control.
// We also add the condition to allow ctrl+a to work when the web browser control is put inside listbox.
if (e.Key == Key.Tab || e.Key == Key.Home || e.Key == Key.End || e.Key == Key.Up
if (e.Key == Key.Tab || e.Key == Key.Home || e.Key == Key.End || e.Key == Key.Up
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right
|| (e.Key == Key.A && Keyboard.Modifiers == ModifierKeys.Control))
{
Expand Down Expand Up @@ -1219,24 +1230,19 @@ private void OnMouseButton(MouseButtonEventArgs e)
switch (e.ChangedButton)
{
case MouseButton.Left:
{
mouseButtonType = MouseButtonType.Left;
break;
}

case MouseButton.Middle:
{
mouseButtonType = MouseButtonType.Middle;
break;
}

case MouseButton.Right:
{
mouseButtonType = MouseButtonType.Right;
break;
}

default:
{
return;
}
}

var modifiers = GetModifiers(e);
Expand Down