map webframe zoom api to use HostZoomMap
This commit is contained in:
		
					parent
					
						
							
								63c0e4cbb1
							
						
					
				
			
			
				commit
				
					
						e3fe3cc490
					
				
			
		
					 9 changed files with 113 additions and 18 deletions
				
			
		| 
						 | 
					@ -819,6 +819,10 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
 | 
				
			||||||
    IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
 | 
					    IPC_MESSAGE_HANDLER(AtomViewHostMsg_Message, OnRendererMessage)
 | 
				
			||||||
    IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
 | 
					    IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_Message_Sync,
 | 
				
			||||||
                                    OnRendererMessageSync)
 | 
					                                    OnRendererMessageSync)
 | 
				
			||||||
 | 
					    IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_SetTemporaryZoomLevel,
 | 
				
			||||||
 | 
					                                    OnSetTemporaryZoomLevel)
 | 
				
			||||||
 | 
					    IPC_MESSAGE_HANDLER_DELAY_REPLY(AtomViewHostMsg_GetZoomLevel,
 | 
				
			||||||
 | 
					                                    OnGetZoomLevel)
 | 
				
			||||||
    IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
 | 
					    IPC_MESSAGE_HANDLER_CODE(ViewHostMsg_SetCursor, OnCursorChange,
 | 
				
			||||||
      handled = false)
 | 
					      handled = false)
 | 
				
			||||||
    IPC_MESSAGE_UNHANDLED(handled = false)
 | 
					    IPC_MESSAGE_UNHANDLED(handled = false)
 | 
				
			||||||
| 
						 | 
					@ -1523,6 +1527,19 @@ double WebContents::GetZoomFactor() {
 | 
				
			||||||
  return content::ZoomLevelToZoomFactor(level);
 | 
					  return content::ZoomLevelToZoomFactor(level);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void WebContents::OnSetTemporaryZoomLevel(double level,
 | 
				
			||||||
 | 
					                                          IPC::Message* reply_msg) {
 | 
				
			||||||
 | 
					  zoom_controller_->SetTemporaryZoomLevel(level);
 | 
				
			||||||
 | 
					  double new_level = zoom_controller_->GetTemporaryZoomLevel();
 | 
				
			||||||
 | 
					  AtomViewHostMsg_SetTemporaryZoomLevel::WriteReplyParams(reply_msg, new_level);
 | 
				
			||||||
 | 
					  Send(reply_msg);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void WebContents::OnGetZoomLevel(IPC::Message* reply_msg) {
 | 
				
			||||||
 | 
					  AtomViewHostMsg_GetZoomLevel::WriteReplyParams(reply_msg, GetZoomLevel());
 | 
				
			||||||
 | 
					  Send(reply_msg);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -352,6 +352,14 @@ class WebContents : public mate::TrackableObject<WebContents>,
 | 
				
			||||||
                             const base::ListValue& args,
 | 
					                             const base::ListValue& args,
 | 
				
			||||||
                             IPC::Message* message);
 | 
					                             IPC::Message* message);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Called when received a synchronous message from renderer to
 | 
				
			||||||
 | 
					  // set temporary zoom level.
 | 
				
			||||||
 | 
					  void OnSetTemporaryZoomLevel(double level, IPC::Message* reply_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Called when received a synchronous message from renderer to
 | 
				
			||||||
 | 
					  // get the zoom level.
 | 
				
			||||||
 | 
					  void OnGetZoomLevel(IPC::Message* reply_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  v8::Global<v8::Value> session_;
 | 
					  v8::Global<v8::Value> session_;
 | 
				
			||||||
  v8::Global<v8::Value> devtools_web_contents_;
 | 
					  v8::Global<v8::Value> devtools_web_contents_;
 | 
				
			||||||
  v8::Global<v8::Value> debugger_;
 | 
					  v8::Global<v8::Value> debugger_;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,6 +22,7 @@ WebContentsZoomController::WebContentsZoomController(
 | 
				
			||||||
    content::WebContents* web_contents)
 | 
					    content::WebContents* web_contents)
 | 
				
			||||||
    : content::WebContentsObserver(web_contents) {
 | 
					    : content::WebContentsObserver(web_contents) {
 | 
				
			||||||
  default_zoom_factor_ = content::kEpsilon;
 | 
					  default_zoom_factor_ = content::kEpsilon;
 | 
				
			||||||
 | 
					  temporary_zoom_level_ = content::kEpsilon;
 | 
				
			||||||
  host_zoom_map_ = content::HostZoomMap::GetForWebContents(web_contents);
 | 
					  host_zoom_map_ = content::HostZoomMap::GetForWebContents(web_contents);
 | 
				
			||||||
  zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind(
 | 
					  zoom_subscription_ = host_zoom_map_->AddZoomLevelChangedCallback(base::Bind(
 | 
				
			||||||
      &WebContentsZoomController::OnZoomLevelChanged, base::Unretained(this)));
 | 
					      &WebContentsZoomController::OnZoomLevelChanged, base::Unretained(this)));
 | 
				
			||||||
| 
						 | 
					@ -43,6 +44,11 @@ void WebContentsZoomController::SetZoomLevel(double level) {
 | 
				
			||||||
  if (!web_contents()->GetRenderViewHost()->IsRenderViewLive() ||
 | 
					  if (!web_contents()->GetRenderViewHost()->IsRenderViewLive() ||
 | 
				
			||||||
      content::ZoomValuesEqual(GetZoomLevel(), level))
 | 
					      content::ZoomValuesEqual(GetZoomLevel(), level))
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!content::ZoomValuesEqual(GetTemporaryZoomLevel(), content::kEpsilon)) {
 | 
				
			||||||
 | 
					    temporary_zoom_level_ = content::kEpsilon;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  auto new_zoom_factor = content::ZoomLevelToZoomFactor(level);
 | 
					  auto new_zoom_factor = content::ZoomLevelToZoomFactor(level);
 | 
				
			||||||
  content::NavigationEntry* entry =
 | 
					  content::NavigationEntry* entry =
 | 
				
			||||||
      web_contents()->GetController().GetLastCommittedEntry();
 | 
					      web_contents()->GetController().GetLastCommittedEntry();
 | 
				
			||||||
| 
						 | 
					@ -54,7 +60,7 @@ void WebContentsZoomController::SetZoomLevel(double level) {
 | 
				
			||||||
    content::HostZoomMap::SetZoomLevel(web_contents(), level);
 | 
					    content::HostZoomMap::SetZoomLevel(web_contents(), level);
 | 
				
			||||||
    // Notify observers of zoom level changes.
 | 
					    // Notify observers of zoom level changes.
 | 
				
			||||||
    FOR_EACH_OBSERVER(WebContentsZoomController::Observer, observers_,
 | 
					    FOR_EACH_OBSERVER(WebContentsZoomController::Observer, observers_,
 | 
				
			||||||
                      OnZoomLevelChanged(web_contents(), level));
 | 
					                      OnZoomLevelChanged(web_contents(), level, false));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -70,6 +76,34 @@ double WebContentsZoomController::GetDefaultZoomFactor() {
 | 
				
			||||||
  return default_zoom_factor_;
 | 
					  return default_zoom_factor_;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					bool WebContentsZoomController::UsesTemporaryZoomLevel() {
 | 
				
			||||||
 | 
					  return !content::ZoomValuesEqual(temporary_zoom_level_, content::kEpsilon);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					double WebContentsZoomController::GetTemporaryZoomLevel() {
 | 
				
			||||||
 | 
					  return temporary_zoom_level_;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void WebContentsZoomController::SetTemporaryZoomLevel(double level) {
 | 
				
			||||||
 | 
					  int render_process_id = web_contents()->GetRenderProcessHost()->GetID();
 | 
				
			||||||
 | 
					  int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID();
 | 
				
			||||||
 | 
					  host_zoom_map_->SetTemporaryZoomLevel(render_process_id, render_view_id,
 | 
				
			||||||
 | 
					                                        level);
 | 
				
			||||||
 | 
					  temporary_zoom_level_ = level;
 | 
				
			||||||
 | 
					  // Notify observers of zoom level changes.
 | 
				
			||||||
 | 
					  FOR_EACH_OBSERVER(WebContentsZoomController::Observer, observers_,
 | 
				
			||||||
 | 
					                    OnZoomLevelChanged(web_contents(), level, true));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void WebContentsZoomController::DidStartNavigation(
 | 
				
			||||||
 | 
					    content::NavigationHandle* navigation_handle) {
 | 
				
			||||||
 | 
					  if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage())
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  int render_process_id = web_contents()->GetRenderProcessHost()->GetID();
 | 
				
			||||||
 | 
					  int render_view_id = web_contents()->GetRenderViewHost()->GetRoutingID();
 | 
				
			||||||
 | 
					  host_zoom_map_->ClearTemporaryZoomLevel(render_process_id, render_view_id);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WebContentsZoomController::DidFinishNavigation(
 | 
					void WebContentsZoomController::DidFinishNavigation(
 | 
				
			||||||
    content::NavigationHandle* navigation_handle) {
 | 
					    content::NavigationHandle* navigation_handle) {
 | 
				
			||||||
  if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
 | 
					  if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted())
 | 
				
			||||||
| 
						 | 
					@ -108,6 +142,14 @@ void WebContentsZoomController::SetZoomFactorOnNavigationIfNeeded(
 | 
				
			||||||
  if (content::ZoomValuesEqual(GetDefaultZoomFactor(), content::kEpsilon))
 | 
					  if (content::ZoomValuesEqual(GetDefaultZoomFactor(), content::kEpsilon))
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!content::ZoomValuesEqual(GetTemporaryZoomLevel(), content::kEpsilon)) {
 | 
				
			||||||
 | 
					    FOR_EACH_OBSERVER(
 | 
				
			||||||
 | 
					        WebContentsZoomController::Observer, observers_,
 | 
				
			||||||
 | 
					        OnZoomLevelChanged(web_contents(), GetTemporaryZoomLevel(), true));
 | 
				
			||||||
 | 
					    temporary_zoom_level_ = content::kEpsilon;
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // When kZoomFactor is available, it takes precedence over
 | 
					  // When kZoomFactor is available, it takes precedence over
 | 
				
			||||||
  // pref store values but if the host has zoom factor set explicitly
 | 
					  // pref store values but if the host has zoom factor set explicitly
 | 
				
			||||||
  // then it takes precendence.
 | 
					  // then it takes precendence.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,6 +5,9 @@
 | 
				
			||||||
#ifndef ATOM_BROWSER_WEB_CONTENTS_ZOOM_CONTROLLER_H_
 | 
					#ifndef ATOM_BROWSER_WEB_CONTENTS_ZOOM_CONTROLLER_H_
 | 
				
			||||||
#define ATOM_BROWSER_WEB_CONTENTS_ZOOM_CONTROLLER_H_
 | 
					#define ATOM_BROWSER_WEB_CONTENTS_ZOOM_CONTROLLER_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <map>
 | 
				
			||||||
 | 
					#include <string>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "content/public/browser/host_zoom_map.h"
 | 
					#include "content/public/browser/host_zoom_map.h"
 | 
				
			||||||
#include "content/public/browser/web_contents_observer.h"
 | 
					#include "content/public/browser/web_contents_observer.h"
 | 
				
			||||||
#include "content/public/browser/web_contents_user_data.h"
 | 
					#include "content/public/browser/web_contents_user_data.h"
 | 
				
			||||||
| 
						 | 
					@ -19,7 +22,8 @@ class WebContentsZoomController
 | 
				
			||||||
  class Observer {
 | 
					  class Observer {
 | 
				
			||||||
   public:
 | 
					   public:
 | 
				
			||||||
    virtual void OnZoomLevelChanged(content::WebContents* web_contents,
 | 
					    virtual void OnZoomLevelChanged(content::WebContents* web_contents,
 | 
				
			||||||
                                    double level) {}
 | 
					                                    double level,
 | 
				
			||||||
 | 
					                                    bool is_temporary) {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   protected:
 | 
					   protected:
 | 
				
			||||||
    virtual ~Observer() {}
 | 
					    virtual ~Observer() {}
 | 
				
			||||||
| 
						 | 
					@ -36,9 +40,13 @@ class WebContentsZoomController
 | 
				
			||||||
  double GetZoomLevel();
 | 
					  double GetZoomLevel();
 | 
				
			||||||
  void SetDefaultZoomFactor(double factor);
 | 
					  void SetDefaultZoomFactor(double factor);
 | 
				
			||||||
  double GetDefaultZoomFactor();
 | 
					  double GetDefaultZoomFactor();
 | 
				
			||||||
 | 
					  void SetTemporaryZoomLevel(double level);
 | 
				
			||||||
 | 
					  bool UsesTemporaryZoomLevel();
 | 
				
			||||||
 | 
					  double GetTemporaryZoomLevel();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 protected:
 | 
					 protected:
 | 
				
			||||||
  // content::WebContentsObserver:
 | 
					  // content::WebContentsObserver:
 | 
				
			||||||
 | 
					  void DidStartNavigation(content::NavigationHandle* handle) override;
 | 
				
			||||||
  void DidFinishNavigation(content::NavigationHandle* handle) override;
 | 
					  void DidFinishNavigation(content::NavigationHandle* handle) override;
 | 
				
			||||||
  void WebContentsDestroyed() override;
 | 
					  void WebContentsDestroyed() override;
 | 
				
			||||||
  void RenderFrameHostChanged(content::RenderFrameHost* old_host,
 | 
					  void RenderFrameHostChanged(content::RenderFrameHost* old_host,
 | 
				
			||||||
| 
						 | 
					@ -55,6 +63,7 @@ class WebContentsZoomController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // kZoomFactor.
 | 
					  // kZoomFactor.
 | 
				
			||||||
  double default_zoom_factor_;
 | 
					  double default_zoom_factor_;
 | 
				
			||||||
 | 
					  double temporary_zoom_level_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Map between zoom factor and hosts in this webContent.
 | 
					  // Map between zoom factor and hosts in this webContent.
 | 
				
			||||||
  std::map<std::string, double> host_zoom_factor_;
 | 
					  std::map<std::string, double> host_zoom_factor_;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -112,6 +112,10 @@ void WebViewGuestDelegate::DidAttach(int guest_proxy_routing_id) {
 | 
				
			||||||
  embedder_zoom_controller_ =
 | 
					  embedder_zoom_controller_ =
 | 
				
			||||||
      WebContentsZoomController::FromWebContents(embedder_web_contents_);
 | 
					      WebContentsZoomController::FromWebContents(embedder_web_contents_);
 | 
				
			||||||
  embedder_zoom_controller_->AddObserver(this);
 | 
					  embedder_zoom_controller_->AddObserver(this);
 | 
				
			||||||
 | 
					  if (embedder_zoom_controller_->UsesTemporaryZoomLevel()) {
 | 
				
			||||||
 | 
					    double level = embedder_zoom_controller_->GetTemporaryZoomLevel();
 | 
				
			||||||
 | 
					    api_web_contents_->GetZoomController()->SetTemporaryZoomLevel(level);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() const {
 | 
					content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() const {
 | 
				
			||||||
| 
						 | 
					@ -141,9 +145,14 @@ void WebViewGuestDelegate::WillAttach(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WebViewGuestDelegate::OnZoomLevelChanged(
 | 
					void WebViewGuestDelegate::OnZoomLevelChanged(
 | 
				
			||||||
    content::WebContents* web_contents,
 | 
					    content::WebContents* web_contents,
 | 
				
			||||||
    double level) {
 | 
					    double level,
 | 
				
			||||||
 | 
					    bool is_temporary) {
 | 
				
			||||||
  if (web_contents == GetOwnerWebContents()) {
 | 
					  if (web_contents == GetOwnerWebContents()) {
 | 
				
			||||||
    api_web_contents_->GetZoomController()->SetZoomLevel(level);
 | 
					    if (is_temporary) {
 | 
				
			||||||
 | 
					      api_web_contents_->GetZoomController()->SetTemporaryZoomLevel(level);
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					      api_web_contents_->GetZoomController()->SetZoomLevel(level);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -67,7 +67,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // WebContentsZoomController::Observer:
 | 
					  // WebContentsZoomController::Observer:
 | 
				
			||||||
  void OnZoomLevelChanged(content::WebContents* web_contents,
 | 
					  void OnZoomLevelChanged(content::WebContents* web_contents,
 | 
				
			||||||
                          double level) override;
 | 
					                          double level,
 | 
				
			||||||
 | 
					                          bool is_temporary) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 private:
 | 
					 private:
 | 
				
			||||||
  // This method is invoked when the contents auto-resized to give the container
 | 
					  // This method is invoked when the contents auto-resized to give the container
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -41,3 +41,11 @@ IPC_MESSAGE_ROUTED1(AtomViewHostMsg_UpdateDraggableRegions,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Update renderer process preferences.
 | 
					// Update renderer process preferences.
 | 
				
			||||||
IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)
 | 
					IPC_MESSAGE_CONTROL1(AtomMsg_UpdatePreferences, base::ListValue)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Sent by renderer to set the temporary zoom level.
 | 
				
			||||||
 | 
					IPC_SYNC_MESSAGE_ROUTED1_1(AtomViewHostMsg_SetTemporaryZoomLevel,
 | 
				
			||||||
 | 
					                           double /* zoom level */,
 | 
				
			||||||
 | 
					                           double /* result */)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Sent by renderer to get the zoom level.
 | 
				
			||||||
 | 
					IPC_SYNC_MESSAGE_ROUTED0_1(AtomViewHostMsg_GetZoomLevel, double /* result */)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4,6 +4,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "atom/renderer/api/atom_api_web_frame.h"
 | 
					#include "atom/renderer/api/atom_api_web_frame.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "atom/common/api/api_messages.h"
 | 
				
			||||||
#include "atom/common/api/event_emitter_caller.h"
 | 
					#include "atom/common/api/event_emitter_caller.h"
 | 
				
			||||||
#include "atom/common/native_mate_converters/blink_converter.h"
 | 
					#include "atom/common/native_mate_converters/blink_converter.h"
 | 
				
			||||||
#include "atom/common/native_mate_converters/callback.h"
 | 
					#include "atom/common/native_mate_converters/callback.h"
 | 
				
			||||||
| 
						 | 
					@ -72,13 +73,21 @@ void WebFrame::SetName(const std::string& name) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double WebFrame::SetZoomLevel(double level) {
 | 
					double WebFrame::SetZoomLevel(double level) {
 | 
				
			||||||
  double ret = web_frame_->view()->setZoomLevel(level);
 | 
					  double result;
 | 
				
			||||||
  mate::EmitEvent(isolate(), GetWrapper(), "zoom-level-changed", ret);
 | 
					  content::RenderView* render_view =
 | 
				
			||||||
  return ret;
 | 
					      content::RenderView::FromWebView(web_frame_->view());
 | 
				
			||||||
 | 
					  render_view->Send(new AtomViewHostMsg_SetTemporaryZoomLevel(
 | 
				
			||||||
 | 
					      render_view->GetRoutingID(), level, &result));
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double WebFrame::GetZoomLevel() const {
 | 
					double WebFrame::GetZoomLevel() const {
 | 
				
			||||||
  return web_frame_->view()->zoomLevel();
 | 
					  double result;
 | 
				
			||||||
 | 
					  content::RenderView* render_view =
 | 
				
			||||||
 | 
					      content::RenderView::FromWebView(web_frame_->view());
 | 
				
			||||||
 | 
					  render_view->Send(
 | 
				
			||||||
 | 
					      new AtomViewHostMsg_GetZoomLevel(render_view->GetRoutingID(), &result));
 | 
				
			||||||
 | 
					  return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
double WebFrame::SetZoomFactor(double factor) {
 | 
					double WebFrame::SetZoomFactor(double factor) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,12 +34,6 @@ class WebViewImpl {
 | 
				
			||||||
    this.viewInstanceId = getNextId()
 | 
					    this.viewInstanceId = getNextId()
 | 
				
			||||||
    shadowRoot.appendChild(this.browserPluginNode)
 | 
					    shadowRoot.appendChild(this.browserPluginNode)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Subscribe to host's zoom level changes.
 | 
					 | 
				
			||||||
    this.onZoomLevelChanged = (zoomLevel) => {
 | 
					 | 
				
			||||||
      this.webviewNode.setZoomLevel(zoomLevel)
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    webFrame.on('zoom-level-changed', this.onZoomLevelChanged)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    this.onVisibilityChanged = (event, visibilityState) => {
 | 
					    this.onVisibilityChanged = (event, visibilityState) => {
 | 
				
			||||||
      this.webviewNode.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', visibilityState)
 | 
					      this.webviewNode.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', visibilityState)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -56,8 +50,6 @@ class WebViewImpl {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Resets some state upon reattaching <webview> element to the DOM.
 | 
					  // Resets some state upon reattaching <webview> element to the DOM.
 | 
				
			||||||
  reset () {
 | 
					  reset () {
 | 
				
			||||||
    // Unlisten the zoom-level-changed event.
 | 
					 | 
				
			||||||
    webFrame.removeListener('zoom-level-changed', this.onZoomLevelChanged)
 | 
					 | 
				
			||||||
    ipcRenderer.removeListener('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged)
 | 
					    ipcRenderer.removeListener('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // If guestInstanceId is defined then the <webview> has navigated and has
 | 
					    // If guestInstanceId is defined then the <webview> has navigated and has
 | 
				
			||||||
| 
						 | 
					@ -230,7 +222,7 @@ class WebViewImpl {
 | 
				
			||||||
  buildParams () {
 | 
					  buildParams () {
 | 
				
			||||||
    const params = {
 | 
					    const params = {
 | 
				
			||||||
      instanceId: this.viewInstanceId,
 | 
					      instanceId: this.viewInstanceId,
 | 
				
			||||||
      userAgentOverride: this.userAgentOverride,
 | 
					      userAgentOverride: this.userAgentOverride
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    for (const attributeName in this.attributes) {
 | 
					    for (const attributeName in this.attributes) {
 | 
				
			||||||
      if (hasProp.call(this.attributes, attributeName)) {
 | 
					      if (hasProp.call(this.attributes, attributeName)) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue