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:
@ -13,6 +13,7 @@
|
||||
#include "include/views/cef_browser_view.h"
|
||||
#include "include/wrapper/cef_stream_resource_handler.h"
|
||||
#include "tests/cefclient/browser/main_context.h"
|
||||
#include "tests/cefclient/browser/root_window.h"
|
||||
#include "tests/cefclient/browser/test_runner.h"
|
||||
#include "tests/cefclient/browser/window_test_runner.h"
|
||||
#include "tests/cefclient/browser/window_test_runner_views.h"
|
||||
@ -40,7 +41,8 @@ const char kMessageTitlebarHeightName[] = "WindowTest.TitlebarHeight";
|
||||
// Create the appropriate platform test runner object.
|
||||
std::unique_ptr<WindowTestRunner> CreateWindowTestRunner(
|
||||
CefRefPtr<CefBrowser> browser) {
|
||||
if (CefBrowserView::GetForBrowser(browser)) {
|
||||
auto root_window = RootWindow::GetForBrowser(browser->GetIdentifier());
|
||||
if (root_window->IsViewsHosted()) {
|
||||
// Browser is Views-hosted.
|
||||
return std::make_unique<WindowTestRunnerViews>();
|
||||
}
|
||||
@ -99,6 +101,20 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
|
||||
return false;
|
||||
}
|
||||
|
||||
RunOnMainThread(browser, request, callback);
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
static void RunOnMainThread(CefRefPtr<CefBrowser> browser,
|
||||
const CefString& request,
|
||||
CefRefPtr<Callback> callback) {
|
||||
if (!CURRENTLY_ON_MAIN_THREAD()) {
|
||||
MAIN_POST_CLOSURE(base::BindOnce(&Handler::RunOnMainThread, browser,
|
||||
request, callback));
|
||||
return;
|
||||
}
|
||||
|
||||
auto runner = CreateWindowTestRunner(browser);
|
||||
|
||||
const std::string& message_name = request;
|
||||
@ -123,7 +139,6 @@ class Handler : public CefMessageRouterBrowserSide::Handler {
|
||||
}
|
||||
|
||||
callback->Success("");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user