Browse Source

Code style fixes

Cheng Zhao 7 years ago
parent
commit
7e0593950c

+ 11 - 11
atom/browser/api/atom_api_web_contents.cc

@@ -909,6 +909,17 @@ void WebContents::DevToolsClosed() {
   Emit("devtools-closed");
 }
 
+void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
+                                    const gfx::RectF& bounds,
+                                    const std::vector<base::string16>& values,
+                                    const std::vector<base::string16>& labels) {
+  auto relay = NativeWindowRelay::FromWebContents(web_contents());
+  if (relay) {
+    relay->window->ShowAutofillPopup(
+        frame_host, web_contents(), bounds, values, labels);
+  }
+}
+
 bool WebContents::OnMessageReceived(const IPC::Message& message) {
   bool handled = true;
   IPC_BEGIN_MESSAGE_MAP(WebContents, message)
@@ -945,17 +956,6 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
   return handled;
 }
 
-void WebContents::ShowAutofillPopup(
-    content::RenderFrameHost* frame_host,
-    const gfx::RectF& bounds,
-    const std::vector<base::string16>& values,
-    const std::vector<base::string16>& labels) {
-  auto relay = NativeWindowRelay::FromWebContents(web_contents());
-  if (relay)
-    relay->window->ShowAutofillPopup(
-      frame_host, web_contents(), bounds, values, labels);
-}
-
 // There are three ways of destroying a webContents:
 // 1. call webContents.destroy();
 // 2. garbage collection;

+ 4 - 5
atom/browser/api/atom_api_web_contents.h

@@ -357,11 +357,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
   void DevToolsOpened() override;
   void DevToolsClosed() override;
 
-  void ShowAutofillPopup(
-    content::RenderFrameHost* frame_host,
-    const gfx::RectF& bounds,
-    const std::vector<base::string16>& values,
-    const std::vector<base::string16>& labels);
+  void ShowAutofillPopup(content::RenderFrameHost* frame_host,
+                         const gfx::RectF& bounds,
+                         const std::vector<base::string16>& values,
+                         const std::vector<base::string16>& labels);
 
  private:
   AtomBrowserContext* GetBrowserContext() const;

+ 1 - 1
atom/browser/api/atom_api_window.cc

@@ -144,7 +144,7 @@ void Window::Init(v8::Isolate* isolate,
       options,
       parent.IsEmpty() ? nullptr : parent->window_.get()));
   web_contents->SetOwnerWindow(window_.get());
-  window_->SetIsOffScreenDummy(api_web_contents_->IsOffScreen());
+  window_->set_is_offscreen_dummy(api_web_contents_->IsOffScreen());
 
 #if defined(TOOLKIT_VIEWS)
   // Sets the window icon.

+ 1 - 1
atom/browser/atom_download_manager_delegate.cc

@@ -92,7 +92,7 @@ void AtomDownloadManagerDelegate::OnDownloadPathGenerated(
   // Show save dialog if save path was not set already on item
   file_dialog::DialogSettings settings;
   settings.parent_window = window;
-  settings.force_detached = window->IsOffScreenDummy();
+  settings.force_detached = window->is_offscreen_dummy();
   settings.title = item->GetURL().spec();
   settings.default_path = default_path;
   if (path.empty() && file_dialog::ShowSaveDialog(settings, &path)) {

+ 6 - 6
atom/browser/common_web_contents_delegate.cc

@@ -242,8 +242,8 @@ void CommonWebContentsDelegate::RunFileChooser(
     content::RenderFrameHost* render_frame_host,
     const content::FileChooserParams& params) {
   if (!web_dialog_helper_)
-    web_dialog_helper_.reset(new WebDialogHelper(owner_window(),
-      owner_window()->IsOffScreenDummy()));
+    web_dialog_helper_.reset(new WebDialogHelper(
+        owner_window(), owner_window()->is_offscreen_dummy()));
   web_dialog_helper_->RunFileChooser(render_frame_host, params);
 }
 
@@ -251,8 +251,8 @@ void CommonWebContentsDelegate::EnumerateDirectory(content::WebContents* guest,
                                                    int request_id,
                                                    const base::FilePath& path) {
   if (!web_dialog_helper_)
-    web_dialog_helper_.reset(new WebDialogHelper(owner_window(),
-      owner_window()->IsOffScreenDummy()));
+    web_dialog_helper_.reset(new WebDialogHelper(
+        owner_window(), owner_window()->is_offscreen_dummy()));
   web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
 }
 
@@ -300,7 +300,7 @@ void CommonWebContentsDelegate::DevToolsSaveToFile(
   } else {
     file_dialog::DialogSettings settings;
     settings.parent_window = owner_window();
-    settings.force_detached = owner_window()->IsOffScreenDummy();
+    settings.force_detached = owner_window()->is_offscreen_dummy();
     settings.title = url;
     settings.default_path = base::FilePath::FromUTF8Unsafe(url);
     if (!file_dialog::ShowSaveDialog(settings, &path)) {
@@ -367,7 +367,7 @@ void CommonWebContentsDelegate::DevToolsAddFileSystem(
     std::vector<base::FilePath> paths;
     file_dialog::DialogSettings settings;
     settings.parent_window = owner_window();
-    settings.force_detached = owner_window()->IsOffScreenDummy();
+    settings.force_detached = owner_window()->is_offscreen_dummy();
     settings.properties = file_dialog::FILE_DIALOG_OPEN_DIRECTORY;
     if (!file_dialog::ShowOpenDialog(settings, &paths))
       return;

+ 3 - 7
atom/browser/native_window.h

@@ -10,7 +10,6 @@
 #include <string>
 #include <vector>
 
-#include "atom/browser/api/atom_api_web_contents.h"
 #include "atom/browser/native_window_observer.h"
 #include "atom/browser/ui/accelerator_util.h"
 #include "atom/browser/ui/atom_menu_model.h"
@@ -237,12 +236,6 @@ class NativeWindow : public base::SupportsUserData,
     const std::vector<base::string16>& values,
     const std::vector<base::string16>& labels) {}
   virtual void HideAutofillPopup(content::RenderFrameHost* frame_host) {}
-  void SetIsOffScreenDummy(bool is_dummy) {
-    is_osr_dummy_ = is_dummy;
-  }
-  bool IsOffScreenDummy() {
-    return is_osr_dummy_;
-  }
 
   // Public API used by platform-dependent delegates and observers to send UI
   // related notifications.
@@ -296,6 +289,9 @@ class NativeWindow : public base::SupportsUserData,
   SkRegion* draggable_region() const { return draggable_region_.get(); }
   bool enable_larger_than_screen() const { return enable_larger_than_screen_; }
 
+  void set_is_offscreen_dummy(bool is_dummy) { is_osr_dummy_ = is_dummy; }
+  bool is_offscreen_dummy() const { return is_osr_dummy_; }
+
   NativeWindow* parent() const { return parent_; }
   bool is_modal() const { return is_modal_; }
 

+ 9 - 8
atom/browser/native_window_views.cc

@@ -1363,17 +1363,18 @@ void NativeWindowViews::ShowAutofillPopup(
     const std::vector<base::string16>& values,
     const std::vector<base::string16>& labels) {
   WebContentsPreferences* web_preferences =
-    WebContentsPreferences::FromWebContents(web_contents);
+      WebContentsPreferences::FromWebContents(web_contents);
 
-  bool isOffsceen = web_preferences->IsOffScreen(web_contents);
-  bool isEmbedderOffscreen = web_preferences->IsGuest(web_contents) &&
-    web_preferences->IsOffScreen(web_preferences->Embedder(web_contents));
+  bool is_offsceen = web_preferences->IsOffScreen(web_contents);
+  bool is_embedder_offscreen =
+      web_preferences->IsGuest(web_contents) &&
+      web_preferences->IsOffScreen(web_preferences->Embedder(web_contents));
 
   autofill_popup_->CreateView(
-    frame_host,
-    isOffsceen || isEmbedderOffscreen,
-    widget(),
-    bounds);
+      frame_host,
+      is_offsceen || is_embedder_offscreen,
+      widget(),
+      bounds);
   autofill_popup_->SetItems(values, labels);
   autofill_popup_->UpdatePopupBounds(menu_bar_visible_ ? 0 : kMenuBarHeight);
 }

+ 19 - 16
atom/browser/ui/autofill_popup.cc

@@ -171,33 +171,36 @@ void AutofillPopup::UpdatePopupBounds(int height_compensation) {
   bool is_rtl = false;
 
   gfx::Point origin(element_bounds_.origin().x(),
-    element_bounds_.origin().y() - height_compensation);
+                    element_bounds_.origin().y() - height_compensation);
   gfx::Rect bounds(origin, element_bounds_.size());
 
-  gfx::Point top_left_corner_of_popup = origin +
-    gfx::Vector2d(bounds.width() - desired_width, -desired_height);
+  gfx::Point top_left_corner_of_popup =
+      origin + gfx::Vector2d(bounds.width() - desired_width, -desired_height);
 
   // This is the bottom right point of the popup if the popup is below the
   // element and grows to the right (since the is the lowest and furthest right
   // the popup could go).
-  gfx::Point bottom_right_corner_of_popup = origin +
-    gfx::Vector2d(desired_width, bounds.height() + desired_height);
+  gfx::Point bottom_right_corner_of_popup =
+      origin + gfx::Vector2d(desired_width, bounds.height() + desired_height);
 
   display::Display top_left_display =
-    GetDisplayNearestPoint(top_left_corner_of_popup, container_view_);
+      GetDisplayNearestPoint(top_left_corner_of_popup, container_view_);
   display::Display bottom_right_display =
-    GetDisplayNearestPoint(bottom_right_corner_of_popup, container_view_);
+      GetDisplayNearestPoint(bottom_right_corner_of_popup, container_view_);
 
   std::pair<int, int> popup_x_and_width =
-    CalculatePopupXAndWidth(top_left_display, bottom_right_display,
-                            desired_width, bounds, is_rtl);
-  std::pair<int, int> popup_y_and_height = CalculatePopupYAndHeight(
-    top_left_display, bottom_right_display, desired_height, bounds);
-
-  popup_bounds_ = gfx::Rect(popup_x_and_width.first, popup_y_and_height.first,
-    popup_x_and_width.second, popup_y_and_height.second);
-  popup_bounds_in_view_ = gfx::Rect(popup_bounds_in_view_.origin(),
-    gfx::Size(popup_x_and_width.second, popup_y_and_height.second));
+      CalculatePopupXAndWidth(top_left_display, bottom_right_display,
+                              desired_width, bounds, is_rtl);
+  std::pair<int, int> popup_y_and_height =
+      CalculatePopupYAndHeight(top_left_display, bottom_right_display,
+                               desired_height, bounds);
+
+  popup_bounds_ = gfx::Rect(
+      popup_x_and_width.first, popup_y_and_height.first,
+      popup_x_and_width.second, popup_y_and_height.second);
+  popup_bounds_in_view_ = gfx::Rect(
+      popup_bounds_in_view_.origin(),
+      gfx::Size(popup_x_and_width.second, popup_y_and_height.second));
   if (view_)
     view_->DoUpdateBoundsAndRedrawPopup();
 }

+ 2 - 2
atom/browser/ui/message_box_mac.mm

@@ -147,7 +147,7 @@ int ShowMessageBox(NativeWindow* parent_window,
   // Use runModal for synchronous alert without parent, since we don't have a
   // window to wait for.
   if (!parent_window || !parent_window->GetNativeWindow() ||
-      parent_window->IsOffScreenDummy())
+      parent_window->is_offscreen_dummy())
     return [[alert autorelease] runModal];
 
   int ret_code = -1;
@@ -186,7 +186,7 @@ void ShowMessageBox(NativeWindow* parent_window,
   // Use runModal for synchronous alert without parent, since we don't have a
   // window to wait for.
   if (!parent_window || !parent_window->GetNativeWindow() ||
-      parent_window->IsOffScreenDummy()) {
+      parent_window->is_offscreen_dummy()) {
     int ret = [[alert autorelease] runModal];
     callback.Run(ret, false);
   } else {

+ 1 - 1
atom/browser/web_dialog_helper.h

@@ -23,7 +23,7 @@ class NativeWindow;
 
 class WebDialogHelper {
  public:
-  explicit WebDialogHelper(NativeWindow* window, bool offscreen);
+  WebDialogHelper(NativeWindow* window, bool offscreen);
   ~WebDialogHelper();
 
   void RunFileChooser(content::RenderFrameHost* render_frame_host,