Rename web-view module to web-frame
This commit is contained in:
parent
4f43c41577
commit
4ccb0cccf3
13 changed files with 116 additions and 120 deletions
8
atom.gyp
8
atom.gyp
|
@ -46,10 +46,10 @@
|
||||||
'atom/renderer/lib/init.coffee',
|
'atom/renderer/lib/init.coffee',
|
||||||
'atom/renderer/lib/inspector.coffee',
|
'atom/renderer/lib/inspector.coffee',
|
||||||
'atom/renderer/lib/override.coffee',
|
'atom/renderer/lib/override.coffee',
|
||||||
'atom/renderer/lib/webview.coffee',
|
'atom/renderer/lib/web-view.coffee',
|
||||||
'atom/renderer/api/lib/ipc.coffee',
|
'atom/renderer/api/lib/ipc.coffee',
|
||||||
'atom/renderer/api/lib/remote.coffee',
|
'atom/renderer/api/lib/remote.coffee',
|
||||||
'atom/renderer/api/lib/web-view.coffee',
|
'atom/renderer/api/lib/web-frame.coffee',
|
||||||
],
|
],
|
||||||
'lib_sources': [
|
'lib_sources': [
|
||||||
'atom/app/atom_content_client.cc',
|
'atom/app/atom_content_client.cc',
|
||||||
|
@ -254,8 +254,8 @@
|
||||||
'atom/renderer/api/atom_api_renderer_ipc.cc',
|
'atom/renderer/api/atom_api_renderer_ipc.cc',
|
||||||
'atom/renderer/api/atom_renderer_bindings.cc',
|
'atom/renderer/api/atom_renderer_bindings.cc',
|
||||||
'atom/renderer/api/atom_renderer_bindings.h',
|
'atom/renderer/api/atom_renderer_bindings.h',
|
||||||
'atom/renderer/api/atom_api_web_view.cc',
|
'atom/renderer/api/atom_api_web_frame.cc',
|
||||||
'atom/renderer/api/atom_api_web_view.h',
|
'atom/renderer/api/atom_api_web_frame.h',
|
||||||
'atom/renderer/atom_render_view_observer.cc',
|
'atom/renderer/atom_render_view_observer.cc',
|
||||||
'atom/renderer/atom_render_view_observer.h',
|
'atom/renderer/atom_render_view_observer.h',
|
||||||
'atom/renderer/atom_renderer_client.cc',
|
'atom/renderer/atom_renderer_client.cc',
|
||||||
|
|
|
@ -26,6 +26,10 @@ module.exports.wrap = (webContents) ->
|
||||||
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
webContents.getId = -> "#{@getProcessId()}-#{@getRoutingId()}"
|
||||||
webContents.equal = (other) -> @getId() is other.getId()
|
webContents.equal = (other) -> @getId() is other.getId()
|
||||||
|
|
||||||
|
# Set frame name of WebContents.
|
||||||
|
webContents.setName = (name) ->
|
||||||
|
@send 'ATOM_SHELL_WEB_CONTENTS_SET_NAME', name
|
||||||
|
|
||||||
# Tell the rpc server that a render view has been deleted and we need to
|
# Tell the rpc server that a render view has been deleted and we need to
|
||||||
# release all objects owned by it.
|
# release all objects owned by it.
|
||||||
webContents.on 'render-view-deleted', (event, processId, routingId) ->
|
webContents.on 'render-view-deleted', (event, processId, routingId) ->
|
||||||
|
|
|
@ -78,7 +78,7 @@ REFERENCE_MODULE(atom_common_screen);
|
||||||
REFERENCE_MODULE(atom_common_shell);
|
REFERENCE_MODULE(atom_common_shell);
|
||||||
REFERENCE_MODULE(atom_common_v8_util);
|
REFERENCE_MODULE(atom_common_v8_util);
|
||||||
REFERENCE_MODULE(atom_renderer_ipc);
|
REFERENCE_MODULE(atom_renderer_ipc);
|
||||||
REFERENCE_MODULE(atom_renderer_web_view);
|
REFERENCE_MODULE(atom_renderer_web_frame);
|
||||||
#undef REFERENCE_MODULE
|
#undef REFERENCE_MODULE
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
81
atom/renderer/api/atom_api_web_frame.cc
Normal file
81
atom/renderer/api/atom_api_web_frame.cc
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/renderer/api/atom_api_web_frame.h"
|
||||||
|
|
||||||
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
|
#include "native_mate/dictionary.h"
|
||||||
|
#include "native_mate/object_template_builder.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||||
|
#include "third_party/WebKit/public/web/WebView.h"
|
||||||
|
|
||||||
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
namespace api {
|
||||||
|
|
||||||
|
WebFrame::WebFrame()
|
||||||
|
: web_frame_(blink::WebLocalFrame::frameForCurrentContext()) {
|
||||||
|
}
|
||||||
|
|
||||||
|
WebFrame::~WebFrame() {
|
||||||
|
}
|
||||||
|
|
||||||
|
double WebFrame::SetZoomLevel(double level) {
|
||||||
|
return web_frame_->view()->setZoomLevel(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
double WebFrame::GetZoomLevel() const {
|
||||||
|
return web_frame_->view()->zoomLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
double WebFrame::SetZoomFactor(double factor) {
|
||||||
|
return blink::WebView::zoomLevelToZoomFactor(SetZoomLevel(
|
||||||
|
blink::WebView::zoomFactorToZoomLevel(factor)));
|
||||||
|
}
|
||||||
|
|
||||||
|
double WebFrame::GetZoomFactor() const {
|
||||||
|
return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel());
|
||||||
|
}
|
||||||
|
|
||||||
|
v8::Handle<v8::Value> WebFrame::RegisterEmbedderCustomElement(
|
||||||
|
const base::string16& name, v8::Handle<v8::Object> options) {
|
||||||
|
blink::WebExceptionCode c = 0;
|
||||||
|
return web_frame_->document().registerEmbedderCustomElement(name, options, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
|
||||||
|
v8::Isolate* isolate) {
|
||||||
|
return mate::ObjectTemplateBuilder(isolate)
|
||||||
|
.SetMethod("setZoomLevel", &WebFrame::SetZoomLevel)
|
||||||
|
.SetMethod("getZoomLevel", &WebFrame::GetZoomLevel)
|
||||||
|
.SetMethod("setZoomFactor", &WebFrame::SetZoomFactor)
|
||||||
|
.SetMethod("getZoomFactor", &WebFrame::GetZoomFactor)
|
||||||
|
.SetMethod("registerEmbedderCustomElement",
|
||||||
|
&WebFrame::RegisterEmbedderCustomElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
mate::Handle<WebFrame> WebFrame::Create(v8::Isolate* isolate) {
|
||||||
|
return CreateHandle(isolate, new WebFrame);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace api
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
|
mate::Dictionary dict(isolate, exports);
|
||||||
|
dict.Set("webFrame", atom::api::WebFrame::Create(isolate));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_frame, Initialize)
|
|
@ -2,27 +2,27 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef ATOM_RENDERER_API_ATOM_API_WEB_VIEW_H_
|
#ifndef ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
||||||
#define ATOM_RENDERER_API_ATOM_API_WEB_VIEW_H_
|
#define ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
||||||
|
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "native_mate/wrappable.h"
|
#include "native_mate/wrappable.h"
|
||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
class WebView;
|
class WebLocalFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
class WebView : public mate::Wrappable {
|
class WebFrame : public mate::Wrappable {
|
||||||
public:
|
public:
|
||||||
static mate::Handle<WebView> Create(v8::Isolate* isolate);
|
static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WebView();
|
WebFrame();
|
||||||
virtual ~WebView();
|
virtual ~WebFrame();
|
||||||
|
|
||||||
double SetZoomLevel(double level);
|
double SetZoomLevel(double level);
|
||||||
double GetZoomLevel() const;
|
double GetZoomLevel() const;
|
||||||
|
@ -36,13 +36,13 @@ class WebView : public mate::Wrappable {
|
||||||
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||||
v8::Isolate* isolate);
|
v8::Isolate* isolate);
|
||||||
|
|
||||||
blink::WebView* web_view_;
|
blink::WebLocalFrame* web_frame_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(WebView);
|
DISALLOW_COPY_AND_ASSIGN(WebFrame);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace api
|
} // namespace api
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
||||||
#endif // ATOM_RENDERER_API_ATOM_API_WEB_VIEW_H_
|
#endif // ATOM_RENDERER_API_ATOM_API_WEB_FRAME_H_
|
|
@ -1,92 +0,0 @@
|
||||||
// Copyright (c) 2014 GitHub, Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the MIT license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "atom/renderer/api/atom_api_web_view.h"
|
|
||||||
|
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
|
||||||
#include "native_mate/dictionary.h"
|
|
||||||
#include "native_mate/object_template_builder.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
|
||||||
#include "third_party/WebKit/public/web/WebView.h"
|
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
|
||||||
|
|
||||||
namespace atom {
|
|
||||||
|
|
||||||
namespace api {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
blink::WebView* GetCurrentWebView() {
|
|
||||||
blink::WebLocalFrame* frame = blink::WebLocalFrame::frameForCurrentContext();
|
|
||||||
if (!frame)
|
|
||||||
return NULL;
|
|
||||||
return frame->view();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
WebView::WebView() : web_view_(GetCurrentWebView()) {
|
|
||||||
}
|
|
||||||
|
|
||||||
WebView::~WebView() {
|
|
||||||
}
|
|
||||||
|
|
||||||
double WebView::SetZoomLevel(double level) {
|
|
||||||
return web_view_->setZoomLevel(level);
|
|
||||||
}
|
|
||||||
|
|
||||||
double WebView::GetZoomLevel() const {
|
|
||||||
return web_view_->zoomLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
double WebView::SetZoomFactor(double factor) {
|
|
||||||
return blink::WebView::zoomLevelToZoomFactor(SetZoomLevel(
|
|
||||||
blink::WebView::zoomFactorToZoomLevel(factor)));
|
|
||||||
}
|
|
||||||
|
|
||||||
double WebView::GetZoomFactor() const {
|
|
||||||
return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel());
|
|
||||||
}
|
|
||||||
|
|
||||||
v8::Handle<v8::Value> WebView::RegisterEmbedderCustomElement(
|
|
||||||
const base::string16& name, v8::Handle<v8::Object> options) {
|
|
||||||
auto document = blink::WebLocalFrame::frameForCurrentContext()->document();
|
|
||||||
blink::WebExceptionCode ec = 0;
|
|
||||||
return document.registerEmbedderCustomElement(name, options, ec);
|
|
||||||
}
|
|
||||||
|
|
||||||
mate::ObjectTemplateBuilder WebView::GetObjectTemplateBuilder(
|
|
||||||
v8::Isolate* isolate) {
|
|
||||||
return mate::ObjectTemplateBuilder(isolate)
|
|
||||||
.SetMethod("setZoomLevel", &WebView::SetZoomLevel)
|
|
||||||
.SetMethod("getZoomLevel", &WebView::GetZoomLevel)
|
|
||||||
.SetMethod("setZoomFactor", &WebView::SetZoomFactor)
|
|
||||||
.SetMethod("getZoomFactor", &WebView::GetZoomFactor)
|
|
||||||
.SetMethod("registerEmbedderCustomElement",
|
|
||||||
&WebView::RegisterEmbedderCustomElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
|
||||||
mate::Handle<WebView> WebView::Create(v8::Isolate* isolate) {
|
|
||||||
return CreateHandle(isolate, new WebView);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace api
|
|
||||||
|
|
||||||
} // namespace atom
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
|
||||||
v8::Handle<v8::Context> context, void* priv) {
|
|
||||||
v8::Isolate* isolate = context->GetIsolate();
|
|
||||||
mate::Dictionary dict(isolate, exports);
|
|
||||||
dict.Set("webView", atom::api::WebView::Create(isolate));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_view, Initialize)
|
|
1
atom/renderer/api/lib/web-frame.coffee
Normal file
1
atom/renderer/api/lib/web-frame.coffee
Normal file
|
@ -0,0 +1 @@
|
||||||
|
module.exports = process.atomBinding('web_frame').webFrame
|
|
@ -1 +0,0 @@
|
||||||
module.exports = process.atomBinding('web_view').webView
|
|
|
@ -1,7 +1,10 @@
|
||||||
ipc = require 'ipc'
|
ipc = require 'ipc'
|
||||||
|
webFrame = require 'web-frame'
|
||||||
|
|
||||||
requestId = 0
|
requestId = 0
|
||||||
|
|
||||||
|
ipc.on 'ATOM_SHELL_WEB_CONTENTS_SET_NAME', (name) ->
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
createGuest: (type, params, callback) ->
|
createGuest: (type, params, callback) ->
|
||||||
requestId++
|
requestId++
|
||||||
|
|
|
@ -57,4 +57,4 @@ else
|
||||||
# Override default web functions.
|
# Override default web functions.
|
||||||
require path.join(__dirname, 'override')
|
require path.join(__dirname, 'override')
|
||||||
# Load webview tag implementation.
|
# Load webview tag implementation.
|
||||||
require path.join(__dirname, 'webview')
|
require path.join(__dirname, 'web-view')
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
v8Util = process.atomBinding 'v8_util'
|
v8Util = process.atomBinding 'v8_util'
|
||||||
guestViewInternal = require './guest-view-internal'
|
guestViewInternal = require './guest-view-internal'
|
||||||
webView = require 'web-view'
|
webFrame = require 'web-frame'
|
||||||
|
|
||||||
# ID generator.
|
# ID generator.
|
||||||
nextId = 0
|
nextId = 0
|
||||||
|
@ -487,7 +487,7 @@ registerBrowserPluginElement = ->
|
||||||
# Load the plugin immediately.
|
# Load the plugin immediately.
|
||||||
unused = this.nonExistentAttribute
|
unused = this.nonExistentAttribute
|
||||||
|
|
||||||
WebView.BrowserPlugin = webView.registerEmbedderCustomElement 'browserplugin',
|
WebView.BrowserPlugin = webFrame.registerEmbedderCustomElement 'browserplugin',
|
||||||
extends: 'object', prototype: proto
|
extends: 'object', prototype: proto
|
||||||
|
|
||||||
delete proto.createdCallback
|
delete proto.createdCallback
|
|
@ -33,7 +33,7 @@ Modules for web page:
|
||||||
|
|
||||||
* [ipc (renderer)](api/ipc-renderer.md)
|
* [ipc (renderer)](api/ipc-renderer.md)
|
||||||
* [remote](api/remote.md)
|
* [remote](api/remote.md)
|
||||||
* [web-view](api/web-view.md)
|
* [web-frame](api/web-frame.md)
|
||||||
|
|
||||||
Modules for both sides:
|
Modules for both sides:
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,26 @@
|
||||||
# web-view
|
# web-frame
|
||||||
|
|
||||||
The `web-view` module can custom the rendering of current web page.
|
The `web-frame` module can custom the rendering of current web page.
|
||||||
|
|
||||||
An example of zooming current page to 200%.
|
An example of zooming current page to 200%.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var webView = require('web-view');
|
var webFrame = require('web-frame');
|
||||||
webView.setZoomFactor(2);
|
webFrame.setZoomFactor(2);
|
||||||
```
|
```
|
||||||
|
|
||||||
## webView.setZoomFactor(factor)
|
## webFrame.setZoomFactor(factor)
|
||||||
|
|
||||||
* `factor` Number - Zoom factor
|
* `factor` Number - Zoom factor
|
||||||
|
|
||||||
Changes the zoom factor to the specified factor, zoom factor is
|
Changes the zoom factor to the specified factor, zoom factor is
|
||||||
zoom percent / 100, so 300% = 3.0.
|
zoom percent / 100, so 300% = 3.0.
|
||||||
|
|
||||||
## webView.getZoomFactor()
|
## webFrame.getZoomFactor()
|
||||||
|
|
||||||
Returns the current zoom factor.
|
Returns the current zoom factor.
|
||||||
|
|
||||||
## webView.setZoomLevel(level)
|
## webFrame.setZoomLevel(level)
|
||||||
|
|
||||||
* `level` Number - Zoom level
|
* `level` Number - Zoom level
|
||||||
|
|
||||||
|
@ -28,6 +28,6 @@ Changes the zoom level to the specified level, 0 is "original size", and each
|
||||||
increment above or below represents zooming 20% larger or smaller to default
|
increment above or below represents zooming 20% larger or smaller to default
|
||||||
limits of 300% and 50% of original size, respectively.
|
limits of 300% and 50% of original size, respectively.
|
||||||
|
|
||||||
## webView.getZoomLevel()
|
## webFrame.getZoomLevel()
|
||||||
|
|
||||||
Returns the current zoom level.
|
Returns the current zoom level.
|
Loading…
Add table
Add a link
Reference in a new issue