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() { WebView::~WebView() {
} }
void WebView::SetZoomLevel(double level) { double WebView::SetZoomLevel(double level) {
web_view_->setZoomLevel(level); return web_view_->setZoomLevel(level);
} }
double WebView::GetZoomLevel() const { double WebView::GetZoomLevel() const {
return web_view_->zoomLevel(); 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( mate::ObjectTemplateBuilder WebView::GetObjectTemplateBuilder(
v8::Isolate* isolate) { v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate) return mate::ObjectTemplateBuilder(isolate)
.SetMethod("setZoomLevel", &WebView::SetZoomLevel) .SetMethod("setZoomLevel", &WebView::SetZoomLevel)
.SetMethod("getZoomLevel", &WebView::GetZoomLevel); .SetMethod("getZoomLevel", &WebView::GetZoomLevel)
.SetMethod("setZoomFactor", &WebView::SetZoomFactor)
.SetMethod("getZoomFactor", &WebView::GetZoomFactor);
} }
// static // static

View file

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