Commit 5d4c9226 authored by ananta's avatar ananta Committed by Commit bot

Ensure that the main window does not render as deactivated when the link...

Ensure that the main window does not render as deactivated when the link disambiguation bubble is displayed.

This uses the existing framework in the BubbleDelegate to disable inactive rendering in the active
widget when the bubble is displayed, etc. Inactive rendering is enabled when the bubble is dismissed.

Changes in this patch are to pass the active widget to the LinkDisambiguationPopup class when it is
created to display the bubble. This class then passes the contents view to the actual bubble.

BUG=421020

Review URL: https://codereview.chromium.org/680643002

Cr-Commit-Position: refs/heads/master@{#301439}
parent 63a5975c
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
class LinkDisambiguationPopup::ZoomBubbleView class LinkDisambiguationPopup::ZoomBubbleView
: public views::BubbleDelegateView { : public views::BubbleDelegateView {
public: public:
ZoomBubbleView(const gfx::Rect& target_rect, ZoomBubbleView(views::Widget* top_level_widget,
const gfx::Rect& target_rect,
const gfx::ImageSkia* zoomed_skia_image, const gfx::ImageSkia* zoomed_skia_image,
const aura::Window* content, const aura::Window* content,
LinkDisambiguationPopup* popup, LinkDisambiguationPopup* popup,
...@@ -48,13 +49,16 @@ class LinkDisambiguationPopup::ZoomBubbleView ...@@ -48,13 +49,16 @@ class LinkDisambiguationPopup::ZoomBubbleView
}; };
LinkDisambiguationPopup::ZoomBubbleView::ZoomBubbleView( LinkDisambiguationPopup::ZoomBubbleView::ZoomBubbleView(
views::Widget* top_level_widget,
const gfx::Rect& target_rect, const gfx::Rect& target_rect,
const gfx::ImageSkia* zoomed_skia_image, const gfx::ImageSkia* zoomed_skia_image,
const aura::Window* content, const aura::Window* content,
LinkDisambiguationPopup* popup, LinkDisambiguationPopup* popup,
const base::Callback<void(ui::GestureEvent*)>& gesture_cb, const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
const base::Callback<void(ui::MouseEvent*)>& mouse_cb) const base::Callback<void(ui::MouseEvent*)>& mouse_cb)
: BubbleDelegateView(NULL, views::BubbleBorder::FLOAT), : BubbleDelegateView(
top_level_widget ? top_level_widget->GetContentsView() : nullptr,
views::BubbleBorder::FLOAT),
scale_(static_cast<float>(zoomed_skia_image->width()) / scale_(static_cast<float>(zoomed_skia_image->width()) /
static_cast<float>(target_rect.width())), static_cast<float>(target_rect.width())),
content_(content), content_(content),
...@@ -149,6 +153,7 @@ LinkDisambiguationPopup::~LinkDisambiguationPopup() { ...@@ -149,6 +153,7 @@ LinkDisambiguationPopup::~LinkDisambiguationPopup() {
} }
void LinkDisambiguationPopup::Show( void LinkDisambiguationPopup::Show(
views::Widget* top_level_widget,
const SkBitmap& zoomed_bitmap, const SkBitmap& zoomed_bitmap,
const gfx::Rect& target_rect, const gfx::Rect& target_rect,
const gfx::NativeView content, const gfx::NativeView content,
...@@ -157,6 +162,7 @@ void LinkDisambiguationPopup::Show( ...@@ -157,6 +162,7 @@ void LinkDisambiguationPopup::Show(
content_ = content; content_ = content;
view_ = new ZoomBubbleView( view_ = new ZoomBubbleView(
top_level_widget,
target_rect, target_rect,
gfx::Image::CreateFrom1xBitmap(zoomed_bitmap).ToImageSkia(), gfx::Image::CreateFrom1xBitmap(zoomed_bitmap).ToImageSkia(),
content_, content_,
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "content/public/browser/web_contents_view_delegate.h" #include "content/public/browser/web_contents_view_delegate.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
#include "ui/views/widget/widget.h"
namespace aura { namespace aura {
class Window; class Window;
...@@ -25,13 +26,15 @@ class LinkDisambiguationPopup { ...@@ -25,13 +26,15 @@ class LinkDisambiguationPopup {
LinkDisambiguationPopup(); LinkDisambiguationPopup();
~LinkDisambiguationPopup(); ~LinkDisambiguationPopup();
// Creates and shows the Popup. |zoomed_bitmap| is the scaled-up image of the // Creates and shows the Popup. |top_level_widget| is the active widget.
// ambiguous web content. |target_rect| is the original, unzoomed rectangle // |zoomed_bitmap| is the scaled-up image of the ambiguous web content.
// in DIPs in the coordinate system of |content|. We will convert received // |target_rect| is the original, unzoomed rectangle in DIPs in the
// coordinate system of |content|. We will convert received
// gestures in the popup to the coordinate system of |content| and as an // gestures in the popup to the coordinate system of |content| and as an
// offset within |target_rect|, and then call the |callback| with the // offset within |target_rect|, and then call the |callback| with the
// transformed coordinates GestureEvent. // transformed coordinates GestureEvent.
void Show(const SkBitmap& zoomed_bitmap, void Show(views::Widget* top_level_widget,
const SkBitmap& zoomed_bitmap,
const gfx::Rect& target_rect, const gfx::Rect& target_rect,
const gfx::NativeView content, const gfx::NativeView content,
const base::Callback<void(ui::GestureEvent*)>& gesture_cb, const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
......
...@@ -183,7 +183,12 @@ void ChromeWebContentsViewDelegateViews::ShowDisambiguationPopup( ...@@ -183,7 +183,12 @@ void ChromeWebContentsViewDelegateViews::ShowDisambiguationPopup(
link_disambiguation_popup_.reset(new LinkDisambiguationPopup); link_disambiguation_popup_.reset(new LinkDisambiguationPopup);
link_disambiguation_popup_->Show( link_disambiguation_popup_->Show(
zoomed_bitmap, target_rect, content, gesture_cb, mouse_cb); views::Widget::GetTopLevelWidgetForNativeView(GetActiveNativeView()),
zoomed_bitmap,
target_rect,
content,
gesture_cb,
mouse_cb);
#endif #endif
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment