From 094df1aab1df28654d371b2088bdd01fc722525a Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 16:44:09 +0700 Subject: [PATCH 1/7] Implementing invalidate --- CefSharp.Core/CefSharp.Core.vcxproj | 1 + CefSharp.Core/CefSharp.Core.vcxproj.filters | 3 +++ CefSharp.Core/ManagedCefBrowserAdapter.h | 13 ++++++++++++- CefSharp.Core/PaintElementType.h | 14 ++++++++++++++ CefSharp.Wpf/ChromiumWebBrowser.cs | 3 +++ build.ps1 | 6 +++--- 6 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 CefSharp.Core/PaintElementType.h diff --git a/CefSharp.Core/CefSharp.Core.vcxproj b/CefSharp.Core/CefSharp.Core.vcxproj index 8e592415a9..07462f0f61 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj +++ b/CefSharp.Core/CefSharp.Core.vcxproj @@ -250,6 +250,7 @@ + diff --git a/CefSharp.Core/CefSharp.Core.vcxproj.filters b/CefSharp.Core/CefSharp.Core.vcxproj.filters index 0879635f56..5d1f81a257 100644 --- a/CefSharp.Core/CefSharp.Core.vcxproj.filters +++ b/CefSharp.Core/CefSharp.Core.vcxproj.filters @@ -94,6 +94,9 @@ Header Files + + Header Files + Header Files diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index 63a97a5791..ccecf1326d 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -7,6 +7,7 @@ #include "Stdafx.h" #include "BrowserSettings.h" #include "MouseButtonType.h" +#include "PaintElementType.h" #include "Internals/RenderClientAdapter.h" #include "Internals/MCefRefPtr.h" #include "Internals/StringVisitor.h" @@ -126,6 +127,16 @@ namespace CefSharp } } + void Invalidate(PaintElementType type) + { + auto cefHost = _renderClientAdapter->TryGetCefHost(); + + if (cefHost != nullptr) + { + cefHost->Invalidate((CefBrowserHost::PaintElementType)type); + } + } + void SendFocusEvent(bool isFocused) { auto cefHost = _renderClientAdapter->TryGetCefHost(); @@ -191,7 +202,7 @@ namespace CefSharp void OnMouseButton(int x, int y, MouseButtonType mouseButtonType, bool mouseUp, int clickCount, CefEventFlags modifiers) { auto cefHost = _renderClientAdapter->TryGetCefHost(); - + if (cefHost != nullptr) { CefMouseEvent mouseEvent; diff --git a/CefSharp.Core/PaintElementType.h b/CefSharp.Core/PaintElementType.h new file mode 100644 index 0000000000..dd6481ce4b --- /dev/null +++ b/CefSharp.Core/PaintElementType.h @@ -0,0 +1,14 @@ +// Copyright © 2010-2014 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. + +#include "include/cef_browser.h" + +namespace CefSharp +{ + public enum class PaintElementType + { + View = CefBrowserHost::PaintElementType::PET_VIEW, + Popup = CefBrowserHost::PaintElementType::PET_POPUP + }; +} \ No newline at end of file diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index c86224ea43..fd5e7cc1c9 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -509,6 +509,9 @@ private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArg var isVisible = (bool)args.NewValue; managedCefBrowserAdapter.WasHidden(!isVisible); + + if (isVisible) + managedCefBrowserAdapter.Invalidate(PaintElementType.View); } private static void OnApplicationExit(object sender, ExitEventArgs e) diff --git a/build.ps1 b/build.ps1 index 696463bdcc..cdb9effeea 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,7 @@ param( [Parameter(Position = 0)] [string] $Target = "nupkg", [Parameter(Position = 1)] - [string] $Version = "39.0.0-pre01", + [string] $Version = "39.0.0-pre01-MB3", [Parameter(Position = 2)] [string] $AssemblyVersion = "39.0.0", [Parameter(Position = 3)] @@ -284,8 +284,8 @@ WriteAssemblyVersion switch -Exact ($Target) { "nupkg" { - #VSX v120 - VSX v110 + VSX v120 + #VSX v110 Nupkg } "nupkg-only" From e6f7ab414c1111aabd115e9f52e101e44345d0b3 Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 18:02:07 +0700 Subject: [PATCH 2/7] Removing test line, was committed by mistake --- CefSharp.Core/MouseButtonType.h | 1 - 1 file changed, 1 deletion(-) diff --git a/CefSharp.Core/MouseButtonType.h b/CefSharp.Core/MouseButtonType.h index 5add4099bc..85bd7cd8fa 100644 --- a/CefSharp.Core/MouseButtonType.h +++ b/CefSharp.Core/MouseButtonType.h @@ -11,6 +11,5 @@ namespace CefSharp Left = CefBrowserHost::MouseButtonType::MBT_LEFT, Middle = CefBrowserHost::MouseButtonType::MBT_MIDDLE, Right = CefBrowserHost::MouseButtonType::MBT_RIGHT, - Blabla }; } \ No newline at end of file From 519e4e86a0ab4a782920ecb748ddb674da6c9124 Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 18:45:12 +0700 Subject: [PATCH 3/7] Adjusting formatting to use space instead of tab --- CefSharp.Core/ManagedCefBrowserAdapter.h | 17 ++++++++--------- CefSharp.Core/MouseButtonType.h | 2 +- CefSharp.Core/PaintElementType.h | 10 +++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index ccecf1326d..2c4838fdbe 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -127,15 +127,15 @@ namespace CefSharp } } - void Invalidate(PaintElementType type) - { - auto cefHost = _renderClientAdapter->TryGetCefHost(); + void Invalidate(PaintElementType type) + { + auto cefHost = _renderClientAdapter->TryGetCefHost(); - if (cefHost != nullptr) - { - cefHost->Invalidate((CefBrowserHost::PaintElementType)type); - } - } + if (cefHost != nullptr) + { + cefHost->Invalidate((CefBrowserHost::PaintElementType)type); + } + } void SendFocusEvent(bool isFocused) { @@ -202,7 +202,6 @@ namespace CefSharp void OnMouseButton(int x, int y, MouseButtonType mouseButtonType, bool mouseUp, int clickCount, CefEventFlags modifiers) { auto cefHost = _renderClientAdapter->TryGetCefHost(); - if (cefHost != nullptr) { CefMouseEvent mouseEvent; diff --git a/CefSharp.Core/MouseButtonType.h b/CefSharp.Core/MouseButtonType.h index 85bd7cd8fa..2a84dc7f0a 100644 --- a/CefSharp.Core/MouseButtonType.h +++ b/CefSharp.Core/MouseButtonType.h @@ -10,6 +10,6 @@ namespace CefSharp { Left = CefBrowserHost::MouseButtonType::MBT_LEFT, Middle = CefBrowserHost::MouseButtonType::MBT_MIDDLE, - Right = CefBrowserHost::MouseButtonType::MBT_RIGHT, + Right = CefBrowserHost::MouseButtonType::MBT_RIGHT }; } \ No newline at end of file diff --git a/CefSharp.Core/PaintElementType.h b/CefSharp.Core/PaintElementType.h index dd6481ce4b..703545ef43 100644 --- a/CefSharp.Core/PaintElementType.h +++ b/CefSharp.Core/PaintElementType.h @@ -6,9 +6,9 @@ namespace CefSharp { - public enum class PaintElementType - { - View = CefBrowserHost::PaintElementType::PET_VIEW, - Popup = CefBrowserHost::PaintElementType::PET_POPUP - }; + public enum class PaintElementType + { + View = CefBrowserHost::PaintElementType::PET_VIEW, + Popup = CefBrowserHost::PaintElementType::PET_POPUP + }; } \ No newline at end of file From 9a65bcb4b44321c4a4410f84e6dccc9db0320672 Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 23:22:52 +0700 Subject: [PATCH 4/7] Reverting changes to build.ps1 file --- build.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.ps1 b/build.ps1 index cdb9effeea..696463bdcc 100644 --- a/build.ps1 +++ b/build.ps1 @@ -3,7 +3,7 @@ param( [Parameter(Position = 0)] [string] $Target = "nupkg", [Parameter(Position = 1)] - [string] $Version = "39.0.0-pre01-MB3", + [string] $Version = "39.0.0-pre01", [Parameter(Position = 2)] [string] $AssemblyVersion = "39.0.0", [Parameter(Position = 3)] @@ -284,8 +284,8 @@ WriteAssemblyVersion switch -Exact ($Target) { "nupkg" { - VSX v120 - #VSX v110 + #VSX v120 + VSX v110 Nupkg } "nupkg-only" From 698751cb1a150677693ef35353d183fc77f84340 Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 23:26:30 +0700 Subject: [PATCH 5/7] Removing unnecessary whiteline changes --- CefSharp.Core/ManagedCefBrowserAdapter.h | 1 + 1 file changed, 1 insertion(+) diff --git a/CefSharp.Core/ManagedCefBrowserAdapter.h b/CefSharp.Core/ManagedCefBrowserAdapter.h index 2c4838fdbe..ee95ecf0f4 100644 --- a/CefSharp.Core/ManagedCefBrowserAdapter.h +++ b/CefSharp.Core/ManagedCefBrowserAdapter.h @@ -202,6 +202,7 @@ namespace CefSharp void OnMouseButton(int x, int y, MouseButtonType mouseButtonType, bool mouseUp, int clickCount, CefEventFlags modifiers) { auto cefHost = _renderClientAdapter->TryGetCefHost(); + if (cefHost != nullptr) { CefMouseEvent mouseEvent; From d68e99b1d21b88d7e4de6a24cf0a7ca02b01076d Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 23:30:13 +0700 Subject: [PATCH 6/7] Changing copyright symbol to avoid encoding issue --- CefSharp.Core/PaintElementType.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CefSharp.Core/PaintElementType.h b/CefSharp.Core/PaintElementType.h index 703545ef43..d382ddc47b 100644 --- a/CefSharp.Core/PaintElementType.h +++ b/CefSharp.Core/PaintElementType.h @@ -1,4 +1,4 @@ -// Copyright © 2010-2014 The CefSharp Authors. All rights reserved. +// Copyright (c) 2010-2014 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. From db517cc2dabfba5e32a6711746fc6add2b72ccd7 Mon Sep 17 00:00:00 2001 From: dimas Date: Thu, 4 Dec 2014 23:33:38 +0700 Subject: [PATCH 7/7] Removing Invalidate call from inside OnIsVisibleChanged, instead making it a method so it can be called from other place if necessary --- CefSharp.Wpf/ChromiumWebBrowser.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/CefSharp.Wpf/ChromiumWebBrowser.cs b/CefSharp.Wpf/ChromiumWebBrowser.cs index fd5e7cc1c9..e1533b42f3 100644 --- a/CefSharp.Wpf/ChromiumWebBrowser.cs +++ b/CefSharp.Wpf/ChromiumWebBrowser.cs @@ -509,9 +509,6 @@ private void OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArg var isVisible = (bool)args.NewValue; managedCefBrowserAdapter.WasHidden(!isVisible); - - if (isVisible) - managedCefBrowserAdapter.Invalidate(PaintElementType.View); } private static void OnApplicationExit(object sender, ExitEventArgs e) @@ -1291,5 +1288,13 @@ public void AddWordToDictionary(string word) managedCefBrowserAdapter.AddWordToDictionary(word); } + // Invalidate the view. The browser will call CefRenderHandler::OnPaint + // asynchronously. This method is only used when window rendering is + // disabled. + public void Invalidate(PaintElementType type) + { + managedCefBrowserAdapter.Invalidate(type); + } + } }