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

Side by Side Diff: chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup.cc

Issue 680643002: Ensure that the main window does not render as deactivated when the link disambiguation bubble is d… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review comments Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 #include "chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup. h" 5 #include "chrome/browser/ui/views/link_disambiguation/link_disambiguation_popup. h"
6 6
7 #include "ui/aura/client/screen_position_client.h" 7 #include "ui/aura/client/screen_position_client.h"
8 #include "ui/events/event.h" 8 #include "ui/events/event.h"
9 #include "ui/events/event_processor.h" 9 #include "ui/events/event_processor.h"
10 #include "ui/events/event_utils.h" 10 #include "ui/events/event_utils.h"
11 #include "ui/events/gesture_event_details.h" 11 #include "ui/events/gesture_event_details.h"
12 #include "ui/gfx/display.h" 12 #include "ui/gfx/display.h"
13 #include "ui/gfx/image/image.h" 13 #include "ui/gfx/image/image.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/screen.h" 15 #include "ui/gfx/screen.h"
16 #include "ui/views/bubble/bubble_delegate.h" 16 #include "ui/views/bubble/bubble_delegate.h"
17 #include "ui/views/controls/image_view.h" 17 #include "ui/views/controls/image_view.h"
18 18
19 class LinkDisambiguationPopup::ZoomBubbleView 19 class LinkDisambiguationPopup::ZoomBubbleView
20 : public views::BubbleDelegateView { 20 : public views::BubbleDelegateView {
21 public: 21 public:
22 ZoomBubbleView(const gfx::Rect& target_rect, 22 ZoomBubbleView(views::Widget* top_level_widget,
23 const gfx::Rect& target_rect,
23 const gfx::ImageSkia* zoomed_skia_image, 24 const gfx::ImageSkia* zoomed_skia_image,
24 const aura::Window* content, 25 const aura::Window* content,
25 LinkDisambiguationPopup* popup, 26 LinkDisambiguationPopup* popup,
26 const base::Callback<void(ui::GestureEvent*)>& gesture_cb, 27 const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
27 const base::Callback<void(ui::MouseEvent*)>& mouse_cb); 28 const base::Callback<void(ui::MouseEvent*)>& mouse_cb);
28 29
29 void Close(); 30 void Close();
30 31
31 private: 32 private:
32 // views::View overrides 33 // views::View overrides
33 virtual gfx::Size GetPreferredSize() const override; 34 virtual gfx::Size GetPreferredSize() const override;
34 virtual void OnGestureEvent(ui::GestureEvent* event) override; 35 virtual void OnGestureEvent(ui::GestureEvent* event) override;
35 virtual void OnMouseEvent(ui::MouseEvent* event) override; 36 virtual void OnMouseEvent(ui::MouseEvent* event) override;
36 37
37 // WidgetObserver overrides 38 // WidgetObserver overrides
38 virtual void OnWidgetClosing(views::Widget* widget) override; 39 virtual void OnWidgetClosing(views::Widget* widget) override;
39 40
40 const float scale_; 41 const float scale_;
41 const aura::Window* content_; 42 const aura::Window* content_;
42 const base::Callback<void(ui::GestureEvent*)> gesture_cb_; 43 const base::Callback<void(ui::GestureEvent*)> gesture_cb_;
43 const base::Callback<void(ui::MouseEvent*)> mouse_cb_; 44 const base::Callback<void(ui::MouseEvent*)> mouse_cb_;
44 LinkDisambiguationPopup* popup_; 45 LinkDisambiguationPopup* popup_;
45 const gfx::Rect target_rect_; 46 const gfx::Rect target_rect_;
46 47
47 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView); 48 DISALLOW_COPY_AND_ASSIGN(ZoomBubbleView);
48 }; 49 };
49 50
50 LinkDisambiguationPopup::ZoomBubbleView::ZoomBubbleView( 51 LinkDisambiguationPopup::ZoomBubbleView::ZoomBubbleView(
52 views::Widget* top_level_widget,
51 const gfx::Rect& target_rect, 53 const gfx::Rect& target_rect,
52 const gfx::ImageSkia* zoomed_skia_image, 54 const gfx::ImageSkia* zoomed_skia_image,
53 const aura::Window* content, 55 const aura::Window* content,
54 LinkDisambiguationPopup* popup, 56 LinkDisambiguationPopup* popup,
55 const base::Callback<void(ui::GestureEvent*)>& gesture_cb, 57 const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
56 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) 58 const base::Callback<void(ui::MouseEvent*)>& mouse_cb)
57 : BubbleDelegateView(NULL, views::BubbleBorder::FLOAT), 59 : BubbleDelegateView(
60 top_level_widget ? top_level_widget->GetContentsView() : nullptr,
61 views::BubbleBorder::FLOAT),
58 scale_(static_cast<float>(zoomed_skia_image->width()) / 62 scale_(static_cast<float>(zoomed_skia_image->width()) /
59 static_cast<float>(target_rect.width())), 63 static_cast<float>(target_rect.width())),
60 content_(content), 64 content_(content),
61 gesture_cb_(gesture_cb), 65 gesture_cb_(gesture_cb),
62 mouse_cb_(mouse_cb), 66 mouse_cb_(mouse_cb),
63 popup_(popup), 67 popup_(popup),
64 target_rect_(target_rect) { 68 target_rect_(target_rect) {
65 views::ImageView* image_view = new views::ImageView(); 69 views::ImageView* image_view = new views::ImageView();
66 image_view->SetBounds( 70 image_view->SetBounds(
67 0, 0, zoomed_skia_image->width(), zoomed_skia_image->height()); 71 0, 0, zoomed_skia_image->width(), zoomed_skia_image->height());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 LinkDisambiguationPopup::LinkDisambiguationPopup() 146 LinkDisambiguationPopup::LinkDisambiguationPopup()
143 : content_(NULL), 147 : content_(NULL),
144 view_(NULL) { 148 view_(NULL) {
145 } 149 }
146 150
147 LinkDisambiguationPopup::~LinkDisambiguationPopup() { 151 LinkDisambiguationPopup::~LinkDisambiguationPopup() {
148 Close(); 152 Close();
149 } 153 }
150 154
151 void LinkDisambiguationPopup::Show( 155 void LinkDisambiguationPopup::Show(
156 views::Widget* top_level_widget,
152 const SkBitmap& zoomed_bitmap, 157 const SkBitmap& zoomed_bitmap,
153 const gfx::Rect& target_rect, 158 const gfx::Rect& target_rect,
154 const gfx::NativeView content, 159 const gfx::NativeView content,
155 const base::Callback<void(ui::GestureEvent*)>& gesture_cb, 160 const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
156 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) { 161 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) {
157 content_ = content; 162 content_ = content;
158 163
159 view_ = new ZoomBubbleView( 164 view_ = new ZoomBubbleView(
165 top_level_widget,
160 target_rect, 166 target_rect,
161 gfx::Image::CreateFrom1xBitmap(zoomed_bitmap).ToImageSkia(), 167 gfx::Image::CreateFrom1xBitmap(zoomed_bitmap).ToImageSkia(),
162 content_, 168 content_,
163 this, 169 this,
164 gesture_cb, 170 gesture_cb,
165 mouse_cb); 171 mouse_cb);
166 172
167 // Center the zoomed bubble over the target rectangle, constrained to the 173 // Center the zoomed bubble over the target rectangle, constrained to the
168 // work area in the current display. Since |target_rect| is provided in 174 // work area in the current display. Since |target_rect| is provided in
169 // |content_| coordinate system, we must convert it into Screen coordinates 175 // |content_| coordinate system, we must convert it into Screen coordinates
(...skipping 19 matching lines...) Expand all
189 void LinkDisambiguationPopup::Close() { 195 void LinkDisambiguationPopup::Close() {
190 if (view_) { 196 if (view_) {
191 view_->Close(); 197 view_->Close();
192 view_ = NULL; 198 view_ = NULL;
193 } 199 }
194 } 200 }
195 201
196 void LinkDisambiguationPopup::InvalidateBubbleView() { 202 void LinkDisambiguationPopup::InvalidateBubbleView() {
197 view_ = NULL; 203 view_ = NULL;
198 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698