Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 9 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 10 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" | 10 #include "chrome/browser/ui/omnibox/omnibox_popup_view.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 OmniboxView* omnibox_view, | 33 OmniboxView* omnibox_view, |
| 34 OmniboxEditModel* edit_model, | 34 OmniboxEditModel* edit_model, |
| 35 LocationBarView* location_bar_view); | 35 LocationBarView* location_bar_view); |
| 36 | 36 |
| 37 // Returns the bounds the popup should be shown at. This is the display bounds | 37 // Returns the bounds the popup should be shown at. This is the display bounds |
| 38 // and includes offsets for the dropshadow which this view's border renders. | 38 // and includes offsets for the dropshadow which this view's border renders. |
| 39 gfx::Rect GetPopupBounds() const; | 39 gfx::Rect GetPopupBounds() const; |
| 40 | 40 |
| 41 virtual void LayoutChildren(); | 41 virtual void LayoutChildren(); |
| 42 | 42 |
| 43 // Overridden from OmniboxPopupView: | 43 // OmniboxPopupView: |
| 44 bool IsOpen() const override; | 44 bool IsOpen() const override; |
| 45 void InvalidateLine(size_t line) override; | 45 void InvalidateLine(size_t line) override; |
| 46 void UpdatePopupAppearance() override; | 46 void UpdatePopupAppearance() override; |
| 47 gfx::Rect GetTargetBounds() override; | 47 gfx::Rect GetTargetBounds() override; |
| 48 void PaintUpdatesNow() override; | 48 void PaintUpdatesNow() override; |
| 49 void OnDragCanceled() override; | 49 void OnDragCanceled() override; |
| 50 | 50 |
| 51 // Overridden from gfx::AnimationDelegate: | 51 // gfx::AnimationDelegate: |
| 52 void AnimationProgressed(const gfx::Animation* animation) override; | 52 void AnimationProgressed(const gfx::Animation* animation) override; |
| 53 | 53 |
| 54 // Overridden from views::View: | 54 // views::View: |
| 55 void Layout() override; | 55 void Layout() override; |
| 56 views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 56 views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
| 57 bool OnMousePressed(const ui::MouseEvent& event) override; | 57 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 58 bool OnMouseDragged(const ui::MouseEvent& event) override; | 58 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 59 void OnMouseReleased(const ui::MouseEvent& event) override; | 59 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 60 void OnMouseCaptureLost() override; | 60 void OnMouseCaptureLost() override; |
| 61 void OnMouseMoved(const ui::MouseEvent& event) override; | 61 void OnMouseMoved(const ui::MouseEvent& event) override; |
| 62 void OnMouseEntered(const ui::MouseEvent& event) override; | 62 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 63 void OnMouseExited(const ui::MouseEvent& event) override; | 63 void OnMouseExited(const ui::MouseEvent& event) override; |
| 64 | 64 |
| 65 // Overridden from ui::EventHandler: | 65 // ui::EventHandler: |
|
Peter Kasting
2015/01/24 02:20:59
Nit: Just nuke this heading and the blank line abo
oshima
2015/01/26 19:48:18
Done.
| |
| 66 void OnGestureEvent(ui::GestureEvent* event) override; | 66 void OnGestureEvent(ui::GestureEvent* event) override; |
| 67 | 67 |
| 68 bool IsSelectedIndex(size_t index) const; | 68 bool IsSelectedIndex(size_t index) const; |
| 69 bool IsHoveredIndex(size_t index) const; | 69 bool IsHoveredIndex(size_t index) const; |
| 70 gfx::Image GetIconIfExtensionMatch(size_t index) const; | 70 gfx::Image GetIconIfExtensionMatch(size_t index) const; |
| 71 bool IsStarredMatch(const AutocompleteMatch& match) const; | 71 bool IsStarredMatch(const AutocompleteMatch& match) const; |
| 72 | 72 |
| 73 int max_match_contents_width() const { | 73 int max_match_contents_width() const { |
| 74 return max_match_contents_width_; | 74 return max_match_contents_width_; |
| 75 } | 75 } |
| 76 | 76 |
| 77 protected: | 77 protected: |
| 78 OmniboxPopupContentsView(const gfx::FontList& font_list, | 78 OmniboxPopupContentsView(const gfx::FontList& font_list, |
| 79 OmniboxView* omnibox_view, | 79 OmniboxView* omnibox_view, |
| 80 OmniboxEditModel* edit_model, | 80 OmniboxEditModel* edit_model, |
| 81 LocationBarView* location_bar_view); | 81 LocationBarView* location_bar_view); |
| 82 ~OmniboxPopupContentsView() override; | 82 ~OmniboxPopupContentsView() override; |
| 83 | 83 |
| 84 LocationBarView* location_bar_view() { return location_bar_view_; } | 84 LocationBarView* location_bar_view() { return location_bar_view_; } |
| 85 | 85 |
| 86 virtual void PaintResultViews(gfx::Canvas* canvas); | 86 virtual void PaintResultViews(gfx::Canvas* canvas); |
| 87 | 87 |
| 88 // Calculates the height needed to show all the results in the model. | 88 // Calculates the height needed to show all the results in the model. |
| 89 virtual int CalculatePopupHeight(); | 89 virtual int CalculatePopupHeight(); |
| 90 virtual OmniboxResultView* CreateResultView(int model_index, | 90 virtual OmniboxResultView* CreateResultView(int model_index, |
| 91 const gfx::FontList& font_list); | 91 const gfx::FontList& font_list); |
| 92 | 92 |
| 93 // Overridden from views::View: | 93 private: |
| 94 class AutocompletePopupWidget; | |
| 95 | |
| 96 // views::View: | |
| 97 const char* GetClassName() const override; | |
| 94 void OnPaint(gfx::Canvas* canvas) override; | 98 void OnPaint(gfx::Canvas* canvas) override; |
| 95 // This method should not be triggered directly as we paint our children | 99 // This method should not be triggered directly as we paint our children |
| 96 // in an un-conventional way inside OnPaint. We use a separate canvas to | 100 // in an un-conventional way inside OnPaint. We use a separate canvas to |
| 97 // paint the children. Hence we override this method to a no-op so that | 101 // paint the children. Hence we override this method to a no-op so that |
| 98 // the view hierarchy does not "accidentally" trigger this. | 102 // the view hierarchy does not "accidentally" trigger this. |
| 99 void PaintChildren(gfx::Canvas* canvas, | 103 void PaintChildren(gfx::Canvas* canvas, |
| 100 const views::CullSet& cull_set) override; | 104 const views::CullSet& cull_set) override; |
| 101 | 105 |
| 102 scoped_ptr<OmniboxPopupModel> model_; | 106 scoped_ptr<OmniboxPopupModel> model_; |
|
Peter Kasting
2015/01/24 02:20:59
Nit: Move down to with other members
oshima
2015/01/26 19:48:18
Done.
| |
| 103 | 107 |
| 104 private: | |
| 105 class AutocompletePopupWidget; | |
| 106 | |
| 107 // views::ViewTargeterDelegate: | 108 // views::ViewTargeterDelegate: |
| 108 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; | 109 views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override; |
| 109 | 110 |
| 110 // Call immediately after construction. | 111 // Call immediately after construction. |
| 111 void Init(); | 112 void Init(); |
| 112 | 113 |
| 113 // Returns true if the model has a match at the specified index. | 114 // Returns true if the model has a match at the specified index. |
| 114 bool HasMatchAt(size_t index) const; | 115 bool HasMatchAt(size_t index) const; |
| 115 | 116 |
| 116 // Returns the match at the specified index within the popup model. | 117 // Returns the match at the specified index within the popup model. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 | 176 |
| 176 // When the dropdown is not wide enough while displaying postfix suggestions, | 177 // When the dropdown is not wide enough while displaying postfix suggestions, |
| 177 // we use the width of widest match contents to shift the suggestions so that | 178 // we use the width of widest match contents to shift the suggestions so that |
| 178 // the widest suggestion just reaches the end edge. | 179 // the widest suggestion just reaches the end edge. |
| 179 int max_match_contents_width_; | 180 int max_match_contents_width_; |
| 180 | 181 |
| 181 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); | 182 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupContentsView); |
| 182 }; | 183 }; |
| 183 | 184 |
| 184 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ | 185 #endif // CHROME_BROWSER_UI_VIEWS_OMNIBOX_OMNIBOX_POPUP_CONTENTS_VIEW_H_ |
| OLD | NEW |