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 @@
class LinkDisambiguationPopup::ZoomBubbleView
: public views::BubbleDelegateView {
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 aura::Window* content,
LinkDisambiguationPopup* popup,
......@@ -48,13 +49,16 @@ class LinkDisambiguationPopup::ZoomBubbleView
};
LinkDisambiguationPopup::ZoomBubbleView::ZoomBubbleView(
views::Widget* top_level_widget,
const gfx::Rect& target_rect,
const gfx::ImageSkia* zoomed_skia_image,
const aura::Window* content,
LinkDisambiguationPopup* popup,
const base::Callback<void(ui::GestureEvent*)>& gesture_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()) /
static_cast<float>(target_rect.width())),
content_(content),
......@@ -149,6 +153,7 @@ LinkDisambiguationPopup::~LinkDisambiguationPopup() {
}
void LinkDisambiguationPopup::Show(
views::Widget* top_level_widget,
const SkBitmap& zoomed_bitmap,
const gfx::Rect& target_rect,
const gfx::NativeView content,
......@@ -157,6 +162,7 @@ void LinkDisambiguationPopup::Show(
content_ = content;
view_ = new ZoomBubbleView(
top_level_widget,
target_rect,
gfx::Image::CreateFrom1xBitmap(zoomed_bitmap).ToImageSkia(),
content_,
......
......@@ -7,6 +7,7 @@
#include "content/public/browser/web_contents_view_delegate.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/widget/widget.h"
namespace aura {
class Window;
......@@ -25,13 +26,15 @@ class LinkDisambiguationPopup {
LinkDisambiguationPopup();
~LinkDisambiguationPopup();
// Creates and shows the Popup. |zoomed_bitmap| is the scaled-up image of the
// ambiguous web content. |target_rect| is the original, unzoomed rectangle
// in DIPs in the coordinate system of |content|. We will convert received
// Creates and shows the Popup. |top_level_widget| is the active widget.
// |zoomed_bitmap| is the scaled-up image of the ambiguous web content.
// |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
// offset within |target_rect|, and then call the |callback| with the
// 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::NativeView content,
const base::Callback<void(ui::GestureEvent*)>& gesture_cb,
......
......@@ -183,7 +183,12 @@ void ChromeWebContentsViewDelegateViews::ShowDisambiguationPopup(
link_disambiguation_popup_.reset(new LinkDisambiguationPopup);
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
}
......
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