mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Support JavaScript window.moveTo/By() and resizeTo/By() (fixes #698)
Adds new CefDisplayHandler::OnContentsBoundsChange and CefDisplayHandler::GetRootWindowScreenRect callbacks. cefclient: Implement the above callbacks and call CefBrowserHost::NotifyScreenInfoChanged when the root window bounds change. cefclient: osr: Use real screen bounds by default. Pass `--fake-screen-bounds` for the old default behavior. Load https://tests/window in cefclient for additional implementation details and usage examples.
This commit is contained in:
86
patch/patches/renderer_host_aura.patch
Normal file
86
patch/patches/renderer_host_aura.patch
Normal file
@ -0,0 +1,86 @@
|
||||
diff --git content/browser/renderer_host/render_widget_host_view_aura.cc content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
index 5867fc3e77326..23656289851bc 100644
|
||||
--- content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
+++ content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string_view>
|
||||
+#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
#include "base/auto_reset.h"
|
||||
@@ -52,6 +53,7 @@
|
||||
#include "content/public/browser/content_browser_client.h"
|
||||
#include "content/public/browser/device_service.h"
|
||||
#include "content/public/browser/render_view_host.h"
|
||||
+#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/common/page_visibility_state.h"
|
||||
#include "services/service_manager/public/cpp/interface_provider.h"
|
||||
#include "third_party/blink/public/common/input/web_input_event.h"
|
||||
@@ -753,6 +755,9 @@ gfx::Rect RenderWidgetHostViewAura::GetViewBounds() {
|
||||
void RenderWidgetHostViewAura::UpdateBackgroundColor() {
|
||||
CHECK(GetBackgroundColor());
|
||||
|
||||
+ if (!window_) {
|
||||
+ return;
|
||||
+ }
|
||||
SkColor color = *GetBackgroundColor();
|
||||
window_->layer()->SetColor(color);
|
||||
}
|
||||
@@ -1102,6 +1107,12 @@ void RenderWidgetHostViewAura::TransformPointToRootSurface(gfx::PointF* point) {
|
||||
}
|
||||
|
||||
gfx::Rect RenderWidgetHostViewAura::GetBoundsInRootWindow() {
|
||||
+ if (!root_window_bounds_callback_.is_null()) {
|
||||
+ if (auto bounds = root_window_bounds_callback_.Run()) {
|
||||
+ return *bounds;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
aura::Window* top_level = window_->GetToplevelWindow();
|
||||
gfx::Rect bounds(top_level->GetBoundsInScreen());
|
||||
|
||||
@@ -2664,6 +2675,16 @@ void RenderWidgetHostViewAura::CreateAuraWindow(aura::client::WindowType type) {
|
||||
window_->layer()->SetColor(GetBackgroundColor() ? *GetBackgroundColor()
|
||||
: SK_ColorWHITE);
|
||||
UpdateFrameSinkIdRegistration();
|
||||
+
|
||||
+ // Do this after |window_| is created to avoid crashes on Win10.
|
||||
+ // See https://crbug.com/761389.
|
||||
+ auto* web_contents =
|
||||
+ WebContents::FromRenderViewHost(RenderViewHost::From(host()));
|
||||
+ if (web_contents) {
|
||||
+ // TODO(mostynb): actually use prefs. Landing this as a separate CL
|
||||
+ // first to rebaseline some unreliable layout tests.
|
||||
+ std::ignore = web_contents->GetOrCreateWebPreferences();
|
||||
+ }
|
||||
}
|
||||
|
||||
void RenderWidgetHostViewAura::UpdateFrameSinkIdRegistration() {
|
||||
diff --git content/browser/renderer_host/render_widget_host_view_aura.h content/browser/renderer_host/render_widget_host_view_aura.h
|
||||
index 6f96b83c36ee0..52cc4b37f0bbe 100644
|
||||
--- content/browser/renderer_host/render_widget_host_view_aura.h
|
||||
+++ content/browser/renderer_host/render_widget_host_view_aura.h
|
||||
@@ -451,6 +451,12 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
|
||||
}
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
||||
+ using RootWindowBoundsCallback =
|
||||
+ base::RepeatingCallback<std::optional<gfx::Rect>()>;
|
||||
+ void SetRootWindowBoundsCallback(const RootWindowBoundsCallback& callback) {
|
||||
+ root_window_bounds_callback_ = callback;
|
||||
+ }
|
||||
+
|
||||
protected:
|
||||
~RenderWidgetHostViewAura() override;
|
||||
|
||||
@@ -874,6 +880,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
|
||||
|
||||
std::optional<display::ScopedDisplayObserver> display_observer_;
|
||||
|
||||
+ RootWindowBoundsCallback root_window_bounds_callback_;
|
||||
+
|
||||
base::WeakPtrFactory<RenderWidgetHostViewAura> weak_ptr_factory_{this};
|
||||
};
|
||||
|
Reference in New Issue
Block a user