Browse Source

build: add missing enable_view_api flag (#14351)

* build: add missing enable_view_api flag

Fixes #14340.

* fix: properly pass a pointer to a SetLayoutManager() call
Alexey Kuzmin 6 years ago
parent
commit
7edd37bca1
2 changed files with 30 additions and 3 deletions
  1. 29 0
      BUILD.gn
  2. 1 3
      atom/browser/api/atom_api_view.cc

+ 29 - 0
BUILD.gn

@@ -38,6 +38,8 @@ declare_args() {
   # need to test with chromium's location provider.
   # Should not be enabled for release build.
   enable_fake_location_provider = !is_official_build
+
+  enable_view_api = false
 }
 
 if (is_mas_build) {
@@ -72,6 +74,9 @@ config("features") {
   if (enable_osr) {
     defines += [ "ENABLE_OSR=1" ]
   }
+  if (enable_view_api) {
+    defines += [ "ENABLE_VIEW_API" ]
+  }
 }
 
 npm_action("atom_browserify_sandbox") {
@@ -175,6 +180,15 @@ asar("js2asar") {
       "lib/renderer/api/desktop-capturer.js",
     ]
   }
+  if (enable_view_api) {
+     sources += [
+      "lib/browser/api/box-layout.js",
+      "lib/browser/api/button.js",
+      "lib/browser/api/label-button.js",
+      "lib/browser/api/layout-manager.js",
+      "lib/browser/api/text-field.js",
+     ]
+   }
   outputs = [
     "$root_out_dir/resources/electron.asar",
   ]
@@ -397,6 +411,21 @@ static_library("electron_lib") {
       "atom/browser/api/atom_api_desktop_capturer.h",
     ]
   }
+
+  if (enable_view_api) {
+    sources += [
+      "atom/browser/api/atom_api_box_layout.cc",
+      "atom/browser/api/atom_api_box_layout.h",
+      "atom/browser/api/atom_api_button.cc",
+      "atom/browser/api/atom_api_button.h",
+      "atom/browser/api/atom_api_label_button.cc",
+      "atom/browser/api/atom_api_label_button.h",
+      "atom/browser/api/atom_api_layout_manager.cc",
+      "atom/browser/api/atom_api_layout_manager.h",
+      "atom/browser/api/atom_api_text_field.cc",
+      "atom/browser/api/atom_api_text_field.h",
+    ]
+  }
 }
 
 electron_paks("packed_resources") {

+ 1 - 3
atom/browser/api/atom_api_view.cc

@@ -26,9 +26,7 @@ View::~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
-  // pointer, remove the "release()" call when we upgraded to it.
-  view()->SetLayoutManager(layout_manager->TakeOver().release());
+  view()->SetLayoutManager(layout_manager->TakeOver());
 }
 
 void View::AddChildView(mate::Handle<View> child) {