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:
@ -136,7 +136,7 @@ index 51c55cb054ae7..df9aa9bc45a67 100644
|
||||
]
|
||||
}
|
||||
diff --git chrome/browser/ui/browser.cc chrome/browser/ui/browser.cc
|
||||
index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
index d45f8f1713c87..de476f1ed4081 100644
|
||||
--- chrome/browser/ui/browser.cc
|
||||
+++ chrome/browser/ui/browser.cc
|
||||
@@ -272,6 +272,25 @@
|
||||
@ -285,7 +285,21 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
}
|
||||
|
||||
void Browser::CloseContents(WebContents* source) {
|
||||
@@ -2177,6 +2246,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
@@ -2157,6 +2226,13 @@ void Browser::CloseContents(WebContents* source) {
|
||||
}
|
||||
|
||||
void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ if (cef_browser_delegate_ &&
|
||||
+ cef_browser_delegate_->SetContentsBoundsEx(source, bounds)) {
|
||||
+ return;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
if (is_type_normal()) {
|
||||
return;
|
||||
}
|
||||
@@ -2177,6 +2253,8 @@ void Browser::SetContentsBounds(WebContents* source, const gfx::Rect& bounds) {
|
||||
}
|
||||
|
||||
void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
@ -294,7 +308,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
std::vector<StatusBubble*> status_bubbles = GetStatusBubbles();
|
||||
for (StatusBubble* status_bubble : status_bubbles) {
|
||||
StatusBubbleViews* status_bubble_views =
|
||||
@@ -2190,6 +2261,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
@@ -2190,6 +2268,17 @@ void Browser::UpdateTargetURL(WebContents* source, const GURL& url) {
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,7 +326,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
void Browser::ContentsMouseEvent(WebContents* source, const ui::Event& event) {
|
||||
const ui::EventType type = event.type();
|
||||
const bool exited = type == ui::EventType::kMouseExited;
|
||||
@@ -2223,9 +2305,23 @@ void Browser::ContentsZoomChange(bool zoom_in) {
|
||||
@@ -2223,9 +2312,23 @@ void Browser::ContentsZoomChange(bool zoom_in) {
|
||||
}
|
||||
|
||||
bool Browser::TakeFocus(content::WebContents* source, bool reverse) {
|
||||
@ -336,7 +350,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
void Browser::BeforeUnloadFired(WebContents* web_contents,
|
||||
bool proceed,
|
||||
bool* proceed_to_fire_unload) {
|
||||
@@ -2338,12 +2434,24 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||
@@ -2338,12 +2441,24 @@ void Browser::WebContentsCreated(WebContents* source_contents,
|
||||
// to track `new_contents` after it is added to its TabModel this override can
|
||||
// be removed.
|
||||
CreateSessionServiceTabHelper(new_contents);
|
||||
@ -361,7 +375,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
// Don't show the page hung dialog when a HTML popup hangs because
|
||||
// the dialog will take the focus and immediately close the popup.
|
||||
RenderWidgetHostView* view = render_widget_host->GetView();
|
||||
@@ -2356,6 +2464,13 @@ void Browser::RendererUnresponsive(
|
||||
@@ -2356,6 +2471,13 @@ void Browser::RendererUnresponsive(
|
||||
void Browser::RendererResponsive(
|
||||
WebContents* source,
|
||||
content::RenderWidgetHost* render_widget_host) {
|
||||
@ -375,7 +389,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
RenderWidgetHostView* view = render_widget_host->GetView();
|
||||
if (view && !render_widget_host->GetView()->IsHTMLFormPopup()) {
|
||||
TabDialogs::FromWebContents(source)->HideHungRendererDialog(
|
||||
@@ -2365,6 +2480,15 @@ void Browser::RendererResponsive(
|
||||
@@ -2365,6 +2487,15 @@ void Browser::RendererResponsive(
|
||||
|
||||
content::JavaScriptDialogManager* Browser::GetJavaScriptDialogManager(
|
||||
WebContents* source) {
|
||||
@ -391,7 +405,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
return javascript_dialogs::TabModalDialogManager::FromWebContents(source);
|
||||
}
|
||||
|
||||
@@ -2400,6 +2524,11 @@ void Browser::DraggableRegionsChanged(
|
||||
@@ -2400,6 +2531,11 @@ void Browser::DraggableRegionsChanged(
|
||||
if (app_controller_) {
|
||||
app_controller_->DraggableRegionsChanged(regions, contents);
|
||||
}
|
||||
@ -403,7 +417,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
}
|
||||
|
||||
std::vector<blink::mojom::RelatedApplicationPtr>
|
||||
@@ -2514,11 +2643,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||
@@ -2514,11 +2650,15 @@ void Browser::EnterFullscreenModeForTab(
|
||||
const blink::mojom::FullscreenOptions& options) {
|
||||
exclusive_access_manager_->fullscreen_controller()->EnterFullscreenModeForTab(
|
||||
requesting_frame, options.display_id);
|
||||
@ -419,7 +433,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
}
|
||||
|
||||
bool Browser::IsFullscreenForTabOrPending(const WebContents* web_contents) {
|
||||
@@ -2728,6 +2861,16 @@ void Browser::RequestMediaAccessPermission(
|
||||
@@ -2728,6 +2868,16 @@ void Browser::RequestMediaAccessPermission(
|
||||
content::WebContents* web_contents,
|
||||
const content::MediaStreamRequest& request,
|
||||
content::MediaResponseCallback callback) {
|
||||
@ -436,7 +450,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
const extensions::Extension* extension =
|
||||
GetExtensionForOrigin(profile_, request.security_origin);
|
||||
MediaCaptureDevicesDispatcher::GetInstance()->ProcessMediaAccessRequest(
|
||||
@@ -3313,9 +3456,11 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
|
||||
@@ -3313,9 +3463,11 @@ void Browser::RemoveScheduledUpdatesFor(WebContents* contents) {
|
||||
// Browser, Getters for UI (private):
|
||||
|
||||
std::vector<StatusBubble*> Browser::GetStatusBubbles() {
|
||||
@ -449,7 +463,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
}
|
||||
|
||||
// We hide the status bar for web apps windows as this matches native
|
||||
@@ -3323,6 +3468,12 @@ std::vector<StatusBubble*> Browser::GetStatusBubbles() {
|
||||
@@ -3323,6 +3475,12 @@ std::vector<StatusBubble*> Browser::GetStatusBubbles() {
|
||||
// mode, as the minimal browser UI includes the status bar.
|
||||
if (web_app::AppBrowserController::IsWebApp(this) &&
|
||||
!app_controller()->HasMinimalUiButtons()) {
|
||||
@ -462,7 +476,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -3476,6 +3627,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||
@@ -3476,6 +3634,8 @@ void Browser::SetAsDelegate(WebContents* web_contents, bool set_delegate) {
|
||||
BookmarkTabHelper::FromWebContents(web_contents)->RemoveObserver(this);
|
||||
web_contents_collection_.StopObserving(web_contents);
|
||||
}
|
||||
@ -471,7 +485,7 @@ index d45f8f1713c87..7d69f3d8bd4cc 100644
|
||||
}
|
||||
|
||||
void Browser::TabDetachedAtImpl(content::WebContents* contents,
|
||||
@@ -3637,6 +3790,14 @@ bool Browser::PictureInPictureBrowserSupportsWindowFeature(
|
||||
@@ -3637,6 +3797,14 @@ bool Browser::PictureInPictureBrowserSupportsWindowFeature(
|
||||
|
||||
bool Browser::SupportsWindowFeatureImpl(WindowFeature feature,
|
||||
bool check_can_support) const {
|
||||
|
@ -1,15 +1,15 @@
|
||||
diff --git content/browser/renderer_host/render_widget_host_view_aura.cc content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
index 5867fc3e77326..54ac130dea600 100644
|
||||
index 5867fc3e77326..23656289851bc 100644
|
||||
--- content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
+++ content/browser/renderer_host/render_widget_host_view_aura.cc
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <limits>
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
+#include <tuple>
|
||||
#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"
|
||||
@ -28,7 +28,20 @@ index 5867fc3e77326..54ac130dea600 100644
|
||||
SkColor color = *GetBackgroundColor();
|
||||
window_->layer()->SetColor(color);
|
||||
}
|
||||
@@ -2664,6 +2669,16 @@ void RenderWidgetHostViewAura::CreateAuraWindow(aura::client::WindowType type) {
|
||||
@@ -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();
|
||||
@ -45,3 +58,29 @@ index 5867fc3e77326..54ac130dea600 100644
|
||||
}
|
||||
|
||||
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