mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
fix: crash on invalid zoomFactor (#22673)
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "shell/browser/api/electron_api_web_contents.h"
|
||||
|
||||
#include <limits>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
@@ -2489,7 +2490,13 @@ double WebContents::GetZoomLevel() const {
|
||||
return zoom_controller_->GetZoomLevel();
|
||||
}
|
||||
|
||||
void WebContents::SetZoomFactor(double factor) {
|
||||
void WebContents::SetZoomFactor(gin_helper::ErrorThrower thrower,
|
||||
double factor) {
|
||||
if (factor < std::numeric_limits<double>::epsilon()) {
|
||||
thrower.ThrowError("'zoomFactor' must be a double greater than 0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
auto level = blink::PageZoomFactorToZoomLevel(factor);
|
||||
SetZoomLevel(level);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user