Add zoom factor APIs alternative to zoom level.

This commit is contained in:
Cheng Zhao 2014-06-16 14:39:29 +08:00
parent accfabf569
commit 8c264b9a07
2 changed files with 17 additions and 4 deletions

View file

@ -32,19 +32,30 @@ WebView::WebView() : web_view_(GetCurrentWebView()) {
WebView::~WebView() {
}
void WebView::SetZoomLevel(double level) {
web_view_->setZoomLevel(level);
double WebView::SetZoomLevel(double level) {
return web_view_->setZoomLevel(level);
}
double WebView::GetZoomLevel() const {
return web_view_->zoomLevel();
}
double WebView::SetZoomFactor(double factor) {
return WebKit::WebView::zoomLevelToZoomFactor(SetZoomLevel(
WebKit::WebView::zoomFactorToZoomLevel(factor)));
}
double WebView::GetZoomFactor() const {
return WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel());
}
mate::ObjectTemplateBuilder WebView::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("setZoomLevel", &WebView::SetZoomLevel)
.SetMethod("getZoomLevel", &WebView::GetZoomLevel);
.SetMethod("getZoomLevel", &WebView::GetZoomLevel)
.SetMethod("setZoomFactor", &WebView::SetZoomFactor)
.SetMethod("getZoomFactor", &WebView::GetZoomFactor);
}
// static

View file

@ -24,8 +24,10 @@ class WebView : public mate::Wrappable {
WebView();
virtual ~WebView();
void SetZoomLevel(double level);
double SetZoomLevel(double level);
double GetZoomLevel() const;
double SetZoomFactor(double factor);
double GetZoomFactor() const;
// mate::Wrappable:
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(