Add new CanZoom/Zoom API (fixes #3284)

Add a simpler CanZoom/Zoom API as an alternative to the more error-prone
SetZoomLevel/GetZoomLevel API. Both APIs are now implemented for both runtimes.
With the Chrome runtime a zoom notification bubble will be displayed unless
CefBrowserSettings.chrome_zoom_bubble is set to STATE_DISABLED.

To test:
- Run cefclient and select zoom entries from the Tests menu.
- chrome: Run cefclient with `--hide-chrome-bubbles` command-line flag to hide
  the zoom notification bubble.
This commit is contained in:
Marshall Greenblatt
2023-10-04 19:46:45 -04:00
parent 238aa32bc2
commit 721b365c10
20 changed files with 338 additions and 80 deletions

View File

@@ -160,16 +160,6 @@ void RunDialogWindowTest(CefRefPtr<CefBrowser> browser) {
std::move(config));
}
void ModifyZoom(CefRefPtr<CefBrowser> browser, double delta) {
if (!CefCurrentlyOn(TID_UI)) {
// Execute on the UI thread.
CefPostTask(TID_UI, base::BindOnce(&ModifyZoom, browser, delta));
return;
}
browser->GetHost()->SetZoomLevel(browser->GetHost()->GetZoomLevel() + delta);
}
const char kPrompt[] = "Prompt.";
const char kPromptFPS[] = "FPS";
const char kPromptDSF[] = "DSF";
@@ -569,13 +559,13 @@ void RunTest(CefRefPtr<CefBrowser> browser, int id) {
RunRequestTest(browser);
break;
case ID_TESTS_ZOOM_IN:
ModifyZoom(browser, 0.5);
browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_IN);
break;
case ID_TESTS_ZOOM_OUT:
ModifyZoom(browser, -0.5);
browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_OUT);
break;
case ID_TESTS_ZOOM_RESET:
browser->GetHost()->SetZoomLevel(0.0);
browser->GetHost()->Zoom(CEF_ZOOM_COMMAND_RESET);
break;
case ID_TESTS_OSR_FPS:
PromptFPS(browser);