Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add webContents 'zoom-changed' event #17747

Merged
merged 5 commits into from May 14, 2019

refactor: simplify code

  • Loading branch information...
miniak committed May 2, 2019
commit bc3ceedbf85f34cc0dcfb7ff847a3ceeab957713
@@ -235,27 +235,6 @@ struct Converter<atom::api::WebContents::Type> {
}
};

template <>
struct Converter<atom::WebContentsZoomController::ZoomDirection> {
static v8::Local<v8::Value> ToV8(
v8::Isolate* isolate,
atom::WebContentsZoomController::ZoomDirection val) {
using ZoomDirection = atom::WebContentsZoomController::ZoomDirection;
std::string direction = "";
switch (val) {
case ZoomDirection::kIn:
direction = "in";
break;
case ZoomDirection::kOut:
direction = "out";
break;
default:
break;
}
return mate::ConvertToV8(isolate, direction);
}
};

} // namespace mate

namespace atom {
@@ -655,11 +634,7 @@ content::KeyboardEventProcessingResult WebContents::PreHandleKeyboardEvent(
}

void WebContents::ContentsZoomChange(bool zoom_in) {
const atom::WebContentsZoomController::ZoomDirection zoom_direction =
zoom_in ? atom::WebContentsZoomController::ZoomDirection::kIn
: atom::WebContentsZoomController::ZoomDirection::kOut;

Emit("zoom-changed", zoom_direction);
Emit("zoom-changed", zoom_in ? "in" : "out");
}

void WebContents::EnterFullscreenModeForTab(
@@ -51,15 +51,6 @@ class WebContentsZoomController
ZOOM_MODE_DISABLED,
};

enum class ZoomDirection {
// Represents a change in zoom where the zoom level is increasing (zooming
// in).
kIn,
// Represents a change in zoom where the zoom level is decreasing (zooming
// out).
kOut
};

explicit WebContentsZoomController(content::WebContents* web_contents);
~WebContentsZoomController() override;

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.