webContents: set zoom levels with HostZoomMap
This commit is contained in:
parent
5e78330c6d
commit
b27c94368d
3 changed files with 30 additions and 6 deletions
|
@ -49,6 +49,7 @@
|
||||||
#include "content/browser/web_contents/web_contents_impl.h"
|
#include "content/browser/web_contents/web_contents_impl.h"
|
||||||
#include "content/common/view_messages.h"
|
#include "content/common/view_messages.h"
|
||||||
#include "content/public/browser/favicon_status.h"
|
#include "content/public/browser/favicon_status.h"
|
||||||
|
#include "content/public/browser/host_zoom_map.h"
|
||||||
#include "content/public/browser/native_web_keyboard_event.h"
|
#include "content/public/browser/native_web_keyboard_event.h"
|
||||||
#include "content/public/browser/navigation_details.h"
|
#include "content/public/browser/navigation_details.h"
|
||||||
#include "content/public/browser/navigation_entry.h"
|
#include "content/public/browser/navigation_entry.h"
|
||||||
|
@ -1498,6 +1499,24 @@ void WebContents::Invalidate() {
|
||||||
osr_rwhv->Invalidate();
|
osr_rwhv->Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebContents::SetZoomLevel(double level) {
|
||||||
|
content::HostZoomMap::SetZoomLevel(web_contents(), level);
|
||||||
|
}
|
||||||
|
|
||||||
|
double WebContents::GetZoomLevel() {
|
||||||
|
return content::HostZoomMap::GetZoomLevel(web_contents());
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebContents::SetZoomFactor(double factor) {
|
||||||
|
auto level = content::ZoomFactorToZoomLevel(factor);
|
||||||
|
SetZoomLevel(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
double WebContents::GetZoomFactor() {
|
||||||
|
auto level = GetZoomLevel();
|
||||||
|
return content::ZoomLevelToZoomFactor(level);
|
||||||
|
}
|
||||||
|
|
||||||
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
v8::Local<v8::Value> WebContents::GetWebPreferences(v8::Isolate* isolate) {
|
||||||
WebContentsPreferences* web_preferences =
|
WebContentsPreferences* web_preferences =
|
||||||
WebContentsPreferences::FromWebContents(web_contents());
|
WebContentsPreferences::FromWebContents(web_contents());
|
||||||
|
@ -1626,6 +1645,10 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
|
.SetMethod("setFrameRate", &WebContents::SetFrameRate)
|
||||||
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
|
.SetMethod("getFrameRate", &WebContents::GetFrameRate)
|
||||||
.SetMethod("invalidate", &WebContents::Invalidate)
|
.SetMethod("invalidate", &WebContents::Invalidate)
|
||||||
|
.SetMethod("setZoomLevel", &WebContents::SetZoomLevel)
|
||||||
|
.SetMethod("getZoomLevel", &WebContents::GetZoomLevel)
|
||||||
|
.SetMethod("setZoomFactor", &WebContents::SetZoomFactor)
|
||||||
|
.SetMethod("getZoomFactor", &WebContents::GetZoomFactor)
|
||||||
.SetMethod("getType", &WebContents::GetType)
|
.SetMethod("getType", &WebContents::GetType)
|
||||||
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
.SetMethod("getWebPreferences", &WebContents::GetWebPreferences)
|
||||||
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
.SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow)
|
||||||
|
|
|
@ -174,6 +174,12 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
||||||
int GetFrameRate() const;
|
int GetFrameRate() const;
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
|
|
||||||
|
// Methods for zoom handling.
|
||||||
|
void SetZoomLevel(double level);
|
||||||
|
double GetZoomLevel();
|
||||||
|
void SetZoomFactor(double factor);
|
||||||
|
double GetZoomFactor();
|
||||||
|
|
||||||
// Callback triggered on permission response.
|
// Callback triggered on permission response.
|
||||||
void OnEnterFullscreenModeForTab(content::WebContents* source,
|
void OnEnterFullscreenModeForTab(content::WebContents* source,
|
||||||
const GURL& origin,
|
const GURL& origin,
|
||||||
|
|
|
@ -105,15 +105,10 @@ const webFrameMethods = [
|
||||||
'insertText',
|
'insertText',
|
||||||
'setLayoutZoomLevelLimits',
|
'setLayoutZoomLevelLimits',
|
||||||
'setVisualZoomLevelLimits',
|
'setVisualZoomLevelLimits',
|
||||||
'setZoomFactor',
|
|
||||||
'setZoomLevel',
|
|
||||||
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
// TODO(kevinsawicki): Remove in 2.0, deprecate before then with warnings
|
||||||
'setZoomLevelLimits'
|
'setZoomLevelLimits'
|
||||||
]
|
]
|
||||||
const webFrameMethodsWithResult = [
|
const webFrameMethodsWithResult = []
|
||||||
'getZoomFactor',
|
|
||||||
'getZoomLevel'
|
|
||||||
]
|
|
||||||
|
|
||||||
const asyncWebFrameMethods = function (requestId, method, callback, ...args) {
|
const asyncWebFrameMethods = function (requestId, method, callback, ...args) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue