зеркало из https://github.com/electron/electron.git
Put View APIs under a build flag
This commit is contained in:
Родитель
2c8dc9e0bd
Коммит
0f7c25fc63
|
@ -23,6 +23,7 @@ View::~View() {
|
|||
delete view_;
|
||||
}
|
||||
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
void View::SetLayoutManager(mate::Handle<LayoutManager> layout_manager) {
|
||||
layout_manager_.Reset(isolate(), layout_manager->GetWrapper());
|
||||
// TODO(zcbenz): New versions of Chrome takes std::unique_ptr instead of raw
|
||||
|
@ -41,6 +42,7 @@ void View::AddChildViewAt(mate::Handle<View> child, size_t index) {
|
|||
isolate(), child->GetWrapper()); // v8::Global(args...)
|
||||
view()->AddChildViewAt(child->view(), index);
|
||||
}
|
||||
#endif
|
||||
|
||||
// static
|
||||
mate::WrappableBase* View::New(mate::Arguments* args) {
|
||||
|
@ -53,10 +55,12 @@ mate::WrappableBase* View::New(mate::Arguments* args) {
|
|||
void View::BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype) {
|
||||
prototype->SetClassName(mate::StringToV8(isolate, "View"));
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate())
|
||||
.SetMethod("setLayoutManager", &View::SetLayoutManager)
|
||||
.SetMethod("addChildView", &View::AddChildView)
|
||||
.SetMethod("addChildViewAt", &View::AddChildViewAt);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
|
|
@ -23,9 +23,11 @@ class View : public mate::TrackableObject<View> {
|
|||
static void BuildPrototype(v8::Isolate* isolate,
|
||||
v8::Local<v8::FunctionTemplate> prototype);
|
||||
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
void SetLayoutManager(mate::Handle<LayoutManager> layout_manager);
|
||||
void AddChildView(mate::Handle<View> view);
|
||||
void AddChildViewAt(mate::Handle<View> view, size_t index);
|
||||
#endif
|
||||
|
||||
views::View* view() const { return view_; }
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
V(atom_browser_app) \
|
||||
V(atom_browser_auto_updater) \
|
||||
V(atom_browser_browser_view) \
|
||||
V(atom_browser_box_layout) \
|
||||
V(atom_browser_content_tracing) \
|
||||
V(atom_browser_debugger) \
|
||||
V(atom_browser_desktop_capturer) \
|
||||
|
@ -39,7 +38,6 @@
|
|||
V(atom_browser_download_item) \
|
||||
V(atom_browser_global_shortcut) \
|
||||
V(atom_browser_in_app_purchase) \
|
||||
V(atom_browser_layout_manager) \
|
||||
V(atom_browser_menu) \
|
||||
V(atom_browser_net) \
|
||||
V(atom_browser_power_monitor) \
|
||||
|
@ -67,6 +65,10 @@
|
|||
V(atom_renderer_ipc) \
|
||||
V(atom_renderer_web_frame)
|
||||
|
||||
#define ELECTRON_VIEW_MODULES(V) \
|
||||
V(atom_browser_box_layout) \
|
||||
V(atom_browser_layout_manager)
|
||||
|
||||
// This is used to load built-in modules. Instead of using
|
||||
// __attribute__((constructor)), we call the _register_<modname>
|
||||
// function for each built-in modules explicitly. This is only
|
||||
|
@ -74,6 +76,9 @@
|
|||
// implementation when calling the NODE_BUILTIN_MODULE_CONTEXT_AWARE.
|
||||
#define V(modname) void _register_##modname();
|
||||
ELECTRON_BUILTIN_MODULES(V)
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
ELECTRON_VIEW_MODULES(V)
|
||||
#endif
|
||||
#undef V
|
||||
|
||||
namespace {
|
||||
|
@ -167,6 +172,9 @@ NodeBindings::~NodeBindings() {
|
|||
void NodeBindings::RegisterBuiltinModules() {
|
||||
#define V(modname) _register_##modname();
|
||||
ELECTRON_BUILTIN_MODULES(V)
|
||||
#if defined(ENABLE_VIEW_API)
|
||||
ELECTRON_VIEW_MODULES(V)
|
||||
#endif
|
||||
#undef V
|
||||
}
|
||||
|
||||
|
|
|
@ -38,6 +38,11 @@
|
|||
'ENABLE_RUN_AS_NODE',
|
||||
],
|
||||
}], # enable_run_as_node
|
||||
['enable_view_api==1', {
|
||||
'defines': [
|
||||
'ENABLE_VIEW_API',
|
||||
],
|
||||
}], # enable_view_api
|
||||
],
|
||||
},
|
||||
'targets': [
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
'enable_osr%': 1, # FIXME(alexeykuzmin)
|
||||
'enable_pdf_viewer%': 0, # FIXME(deepak1556)
|
||||
'enable_run_as_node%': 1,
|
||||
'enable_view_api%': 0,
|
||||
},
|
||||
'enable_osr%': '<(enable_osr)',
|
||||
'enable_pdf_viewer%': '<(enable_pdf_viewer)',
|
||||
'enable_run_as_node%': '<(enable_run_as_node)',
|
||||
'enable_view_api%': '<(enable_view_api)',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
'lib/browser/api/auto-updater/auto-updater-native.js',
|
||||
'lib/browser/api/auto-updater/auto-updater-win.js',
|
||||
'lib/browser/api/auto-updater/squirrel-update-win.js',
|
||||
'lib/browser/api/box-layout.js',
|
||||
'lib/browser/api/browser-view.js',
|
||||
'lib/browser/api/browser-window.js',
|
||||
'lib/browser/api/content-tracing.js',
|
||||
|
@ -22,7 +21,6 @@
|
|||
'lib/browser/api/global-shortcut.js',
|
||||
'lib/browser/api/ipc-main.js',
|
||||
'lib/browser/api/in-app-purchase.js',
|
||||
'lib/browser/api/layout-manager.js',
|
||||
'lib/browser/api/menu-item-roles.js',
|
||||
'lib/browser/api/menu-item.js',
|
||||
'lib/browser/api/menu-utils.js',
|
||||
|
@ -115,8 +113,6 @@
|
|||
'atom/browser/api/atom_api_app.h',
|
||||
'atom/browser/api/atom_api_auto_updater.cc',
|
||||
'atom/browser/api/atom_api_auto_updater.h',
|
||||
'atom/browser/api/atom_api_box_layout.cc',
|
||||
'atom/browser/api/atom_api_box_layout.h',
|
||||
'atom/browser/api/atom_api_browser_view.cc',
|
||||
'atom/browser/api/atom_api_browser_view.h',
|
||||
'atom/browser/api/atom_api_content_tracing.cc',
|
||||
|
@ -133,8 +129,6 @@
|
|||
'atom/browser/api/atom_api_global_shortcut.h',
|
||||
'atom/browser/api/atom_api_in_app_purchase.cc',
|
||||
'atom/browser/api/atom_api_in_app_purchase.h',
|
||||
'atom/browser/api/atom_api_layout_manager.cc',
|
||||
'atom/browser/api/atom_api_layout_manager.h',
|
||||
'atom/browser/api/atom_api_menu.cc',
|
||||
'atom/browser/api/atom_api_menu.h',
|
||||
'atom/browser/api/atom_api_menu_mac.h',
|
||||
|
@ -781,6 +775,18 @@
|
|||
'atom/app/node_main.h',
|
||||
],
|
||||
}], # enable_run_as_node
|
||||
['enable_view_api==1', {
|
||||
'js_sources': [
|
||||
'lib/browser/api/box-layout.js',
|
||||
'lib/browser/api/layout-manager.js',
|
||||
],
|
||||
'lib_sources': [
|
||||
'atom/browser/api/atom_api_box_layout.cc',
|
||||
'atom/browser/api/atom_api_box_layout.h',
|
||||
'atom/browser/api/atom_api_layout_manager.cc',
|
||||
'atom/browser/api/atom_api_layout_manager.h',
|
||||
],
|
||||
}], # enable_view_api
|
||||
['mas_build==1', {
|
||||
'lib_sources': [
|
||||
'atom/browser/api/atom_api_app_mas.mm',
|
||||
|
|
Загрузка…
Ссылка в новой задаче