Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(311)

Unified Diff: chrome/browser/ui/autofill/autofill_popup_view_helper.h

Issue 1570783003: [Autofill] Move functions from the AutofillPopupController to AutofillPopupLayoutModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: controller now owns the helper Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/autofill/autofill_popup_view_helper.h
diff --git a/chrome/browser/ui/autofill/autofill_popup_view_helper.h b/chrome/browser/ui/autofill/autofill_popup_view_helper.h
new file mode 100644
index 0000000000000000000000000000000000000000..7923524d91ffceef3c702ab3f134f1d29052427d
--- /dev/null
+++ b/chrome/browser/ui/autofill/autofill_popup_view_helper.h
@@ -0,0 +1,98 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_VIEW_HELPER_H_
+#define CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_VIEW_HELPER_H_
+
+#include <stddef.h>
+
+#include "base/strings/string16.h"
+#include "chrome/browser/ui/autofill/autofill_popup_view_delegate.h"
+#include "chrome/browser/ui/autofill/popup_view_common.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace gfx {
+class Display;
+class Point;
+}
+
+namespace ui {
+class KeyEvent;
+}
+
+namespace autofill {
+
+// Helper class which keeps tracks of popup bounds and related view information.
+// TODO(mathp): This should ideally be owned by the view, and not the popup
Evan Stade 2016/01/20 04:51:17 this comment is a bit long, I'd leave it at the ge
Mathieu 2016/01/20 17:57:44 Done.
+// controller. However since the controller interface is being used by both
+// Autofill and the Password Generation popup, some more refactoring is needed
+// in order to move more view-related things from the PopupController to each of
+// the implementer's views.
+class AutofillPopupViewHelper {
Evan Stade 2016/01/20 04:51:17 can we call this something like LayoutModel instea
Mathieu 2016/01/20 17:57:44 Sure I like the name
+ public:
+ explicit AutofillPopupViewHelper(AutofillPopupViewDelegate* delegate);
+
+ // The minimum amount of padding between the Autofill name and subtext,
+ // in pixels.
+ static const size_t kNamePadding = 15;
+
+ // The amount of padding between icons in pixels.
+ static const int kIconPadding = 5;
+
+ // The amount of padding at the end of the popup in pixels.
+ static const int kEndPadding = 3;
+
+#if !defined(OS_ANDROID)
+ // Calculates the desired height of the popup based on its contents.
+ int GetDesiredPopupHeight() const;
+
+ // Calculates the desired width of the popup based on its contents.
+ int GetDesiredPopupWidth() const;
+
+ // Calculate the width of the row, excluding all the text. This provides
+ // the size of the row that won't be reducible (since all the text can be
+ // elided if there isn't enough space). |with_label| indicates whether a label
+ // is expected to be present.
+ int RowWidthWithoutText(int row, bool with_label) const;
+
+ // Get the available space for the total text width. |with_label| indicates
+ // whether a label is expected to be present.
+ int GetAvailableWidthForRow(int row, bool with_label) const;
+
+ // Calculates and sets the bounds of the popup, including placing it properly
+ // to prevent it from going off the screen.
+ void UpdatePopupBounds();
+#endif
+
+ // Convert a y-coordinate to the closest line.
+ int LineFromY(int y);
Evan Stade 2016/01/20 04:51:17 could this be const?
Mathieu 2016/01/20 17:57:44 Done.
+
+ const gfx::Rect popup_bounds() const { return popup_bounds_; }
+
+ // Returns the bounds of the item at |index| in the popup, relative to
+ // the top left of the popup.
+ gfx::Rect GetRowBounds(size_t index);
Evan Stade 2016/01/20 04:51:17 could this be const?
Mathieu 2016/01/20 17:57:44 Done.
+
+ // Gets the resource value for the given resource, returning -1 if the
+ // resource isn't recognized.
+ int GetIconResourceID(const base::string16& resource_name) const;
+
+ private:
+ // Returns the enclosing rectangle for the element_bounds.
+ const gfx::Rect RoundedElementBounds() const;
+
+ // The bounds of the Autofill popup.
+ gfx::Rect popup_bounds_;
+
+ PopupViewCommon view_common_;
+
+ AutofillPopupViewDelegate* delegate_; // Weak reference.
+
+ DISALLOW_COPY_AND_ASSIGN(AutofillPopupViewHelper);
+};
+
+} // namespace autofill
+
+#endif // CHROME_BROWSER_UI_AUTOFILL_AUTOFILL_POPUP_VIEW_HELPER_H_

Powered by Google App Engine
This is Rietveld 408576698