diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 21:29:36 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-02 21:29:36 +0000 |
commit | 1138ccee095823e0c05ec084f19fbabe96b8f0a3 (patch) | |
tree | 3e456a5aa0a97f5bf0a430e2dacb24eea59101db /content/browser | |
parent | 70f48c0a4cfc3675313ad7e8262a6e6b72583690 (diff) | |
download | chromium_src-1138ccee095823e0c05ec084f19fbabe96b8f0a3.zip chromium_src-1138ccee095823e0c05ec084f19fbabe96b8f0a3.tar.gz chromium_src-1138ccee095823e0c05ec084f19fbabe96b8f0a3.tar.bz2 |
Implement SetVisuallyDeemphasized in ChromeRenderViewObserver.
Implement SetVisuallyDeemphasized in ChromeRenderViewObserver
- Add a ChromeViewMsg_SetVisuallyDeemphasized and use it to toggle background dimming on web contents via ChromeRenderViewObserver;
- Derive WebViewColorOverlay from WebKit::WebPageOverlay and add to web view when need to dimming the background;
- Remove RWHV SetVisuallyDeemphasized since it's no longer used;
BUG=103386
TEST=Verify fix for 103386, dimming should show up even when accelerated compositing is on.
Review URL: http://codereview.chromium.org/8730001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112787 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
10 files changed, 12 insertions, 182 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index da26576..5830ad33 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -288,14 +288,6 @@ class RenderWidgetHostView { virtual gfx::PluginWindowHandle GetCompositingSurface() = 0; - // Toggles visual muting of the render view area. This is on when a - // constrained window is showing, for example. |color| is the shade of - // the overlay that covers the render view. If |animate| is true, the overlay - // gradually fades in; otherwise it takes effect immediately. To remove the - // fade effect, pass a NULL value for |color|. In this case, |animate| is - // ignored. - virtual void SetVisuallyDeemphasized(const SkColor* color, bool animate) = 0; - virtual void UnhandledWheelEvent(const WebKit::WebMouseWheelEvent& event) = 0; virtual void SetHasHorizontalScrollbar(bool has_horizontal_scrollbar) = 0; diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index c642aca..90d23e0 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -409,12 +409,6 @@ gfx::Rect RenderWidgetHostViewAura::GetRootWindowBounds() { return window_->GetScreenBounds(); } -void RenderWidgetHostViewAura::SetVisuallyDeemphasized(const SkColor* color, - bool animate) { - // http://crbug.com/102568 - NOTIMPLEMENTED(); -} - void RenderWidgetHostViewAura::UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) { // Not needed. Mac-only. diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index ebd0e44..28dfe4e 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -93,8 +93,6 @@ class CONTENT_EXPORT RenderWidgetHostViewAura virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; virtual gfx::Rect GetRootWindowBounds() OVERRIDE; - virtual void SetVisuallyDeemphasized(const SkColor* color, - bool animate) OVERRIDE; virtual void UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void SetHasHorizontalScrollbar( diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index fedcbd2..2efe680 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -57,9 +57,6 @@ namespace { const int kMaxWindowWidth = 4000; const int kMaxWindowHeight = 4000; -// The duration of the fade-out animation. See |overlay_animation_|. -const int kFadeEffectDuration = 300; - #if defined(OS_CHROMEOS) // TODO(davemoore) Under Chromeos we are increasing the rate that the trackpad // generates events to get better precisions. Eventually we will coordinate the @@ -567,8 +564,6 @@ RenderWidgetHostViewGtk::RenderWidgetHostViewGtk(RenderWidgetHost* widget_host) is_hidden_(false), is_loading_(false), is_showing_context_menu_(false), - overlay_color_(0), - overlay_animation_(this), parent_(NULL), is_popup_first_mouse_release_(true), was_imcontext_focused_before_grab_(false), @@ -590,8 +585,6 @@ RenderWidgetHostViewGtk::~RenderWidgetHostViewGtk() { void RenderWidgetHostViewGtk::InitAsChild() { DoSharedInit(); - overlay_animation_.SetDuration(kFadeEffectDuration); - overlay_animation_.SetSlideDuration(kFadeEffectDuration); gtk_widget_show(view_.get()); } @@ -1110,45 +1103,8 @@ void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { // period where this object isn't attached to a window but hasn't been // Destroy()ed yet and it receives paint messages... if (window) { - if (SkColorGetA(overlay_color_) == 0) { - // In the common case, use XCopyArea. We don't draw more than once, so - // we don't need to double buffer. - backing_store->XShowRect(gfx::Point(0, 0), - paint_rect, ui::GetX11WindowFromGtkWidget(view_.get())); - } else { - // If the grey blend is showing, we make two drawing calls. Use double - // buffering to prevent flicker. Use CairoShowRect because XShowRect - // shortcuts GDK's double buffering. We won't be able to draw outside - // of |damage_rect|, so invalidate the difference between |paint_rect| - // and |damage_rect|. - if (paint_rect != damage_rect) { - GdkRectangle extra_gdk_rect = - paint_rect.Subtract(damage_rect).ToGdkRectangle(); - gdk_window_invalidate_rect(window, &extra_gdk_rect, false); - } - - GdkRectangle rect = { damage_rect.x(), damage_rect.y(), - damage_rect.width(), damage_rect.height() }; - gdk_window_begin_paint_rect(window, &rect); - - backing_store->CairoShowRect(damage_rect, GDK_DRAWABLE(window)); - - cairo_t* cr = gdk_cairo_create(window); - gdk_cairo_rectangle(cr, &rect); - SkColor overlay = SkColorSetA( - overlay_color_, - SkColorGetA(overlay_color_) * - overlay_animation_.GetCurrentValue()); - float r = SkColorGetR(overlay) / 255.; - float g = SkColorGetG(overlay) / 255.; - float b = SkColorGetB(overlay) / 255.; - float a = SkColorGetA(overlay) / 255.; - cairo_set_source_rgba(cr, r, g, b, a); - cairo_fill(cr); - cairo_destroy(cr); - - gdk_window_end_paint(window); - } + backing_store->XShowRect(gfx::Point(0, 0), + paint_rect, ui::GetX11WindowFromGtkWidget(view_.get())); } if (!whiteout_start_time_.is_null()) { base::TimeDelta whiteout_duration = base::TimeTicks::Now() - @@ -1206,24 +1162,6 @@ void RenderWidgetHostViewGtk::DestroyPluginContainer( plugin_container_manager_.DestroyPluginContainer(id); } -void RenderWidgetHostViewGtk::SetVisuallyDeemphasized( - const SkColor* color, bool animate) { - // Do nothing unless |color| has changed, meaning |animate| is only - // respected for the first call. - if (color && (*color == overlay_color_)) - return; - - overlay_color_ = color ? *color : 0; - - if (animate) { - overlay_animation_.Reset(); - overlay_animation_.Show(); - } else { - overlay_animation_.Reset(1.0); - gtk_widget_queue_draw(view_.get()); - } -} - void RenderWidgetHostViewGtk::UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) { } @@ -1363,20 +1301,6 @@ void RenderWidgetHostViewGtk::ForwardKeyboardEvent( host_->ForwardKeyboardEvent(event); } -void RenderWidgetHostViewGtk::AnimationEnded(const ui::Animation* animation) { - gtk_widget_queue_draw(view_.get()); -} - -void RenderWidgetHostViewGtk::AnimationProgressed( - const ui::Animation* animation) { - gtk_widget_queue_draw(view_.get()); -} - -void RenderWidgetHostViewGtk::AnimationCanceled( - const ui::Animation* animation) { - gtk_widget_queue_draw(view_.get()); -} - void RenderWidgetHostViewGtk::set_last_mouse_down(GdkEventButton* event) { GdkEventButton* temp = NULL; if (event) { diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 8eb1a29..43deaa7 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -44,8 +44,7 @@ typedef struct _GtkSelectionData GtkSelectionData; // ----------------------------------------------------------------------------- // See comments in render_widget_host_view.h about this class and its members. // ----------------------------------------------------------------------------- -class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView, - public ui::AnimationDelegate { +class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView { public: explicit RenderWidgetHostViewGtk(RenderWidgetHost* widget); virtual ~RenderWidgetHostViewGtk(); @@ -104,8 +103,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView, virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE; virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE; - virtual void SetVisuallyDeemphasized(const SkColor* color, - bool animate) OVERRIDE; virtual void UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void SetHasHorizontalScrollbar( @@ -118,11 +115,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView, virtual bool LockMouse() OVERRIDE; virtual void UnlockMouse() OVERRIDE; - // ui::AnimationDelegate implementation. - virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; - virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; - gfx::NativeView native_view() const { return view_.get(); } // If the widget is aligned with an edge of the monitor its on and the user @@ -223,14 +215,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView, // The time it took after this view was selected for it to be fully painted. base::TimeTicks tab_switch_paint_time_; - // A color we use to shade the entire render view. If 100% transparent, we do - // not shade the render view. - SkColor overlay_color_; - - // The animation used for the abovementioned shade effect. The animation's - // value affects the alpha we use for |overlay_color_|. - ui::SlideAnimation overlay_animation_; - // The native view of our parent widget. Used only for popups. GtkWidget* parent_; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index aad12de..074b88d 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -278,9 +278,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // to be reloaded. void ForceTextureReload(); - virtual void SetVisuallyDeemphasized(const SkColor* color, - bool animate) OVERRIDE; - virtual void UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void SetHasHorizontalScrollbar( diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 4e16f87..d09b0e6 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -987,11 +987,6 @@ void RenderWidgetHostViewMac::ForceTextureReload() { plugin_container_manager_.ForceTextureReload(); } -void RenderWidgetHostViewMac::SetVisuallyDeemphasized(const SkColor* color, - bool animate) { - // This is not used on mac. -} - void RenderWidgetHostViewMac::UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) { [cocoa_view_ gotUnhandledWheelEvent]; diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index be206c3..e315a5f 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -153,31 +153,6 @@ BOOL CALLBACK DetachPluginWindowsCallback(HWND window, LPARAM param) { return TRUE; } -// Draw the contents of |backing_store_dc| onto |paint_rect| with a 70% grey -// filter. -void DrawDeemphasized(const SkColor& color, - const gfx::Rect& paint_rect, - HDC backing_store_dc, - HDC paint_dc) { - gfx::CanvasSkia canvas(paint_rect.width(), paint_rect.height(), true); - { - skia::ScopedPlatformPaint scoped_platform_paint(canvas.sk_canvas()); - HDC dc = scoped_platform_paint.GetPlatformSurface(); - BitBlt(dc, - 0, - 0, - paint_rect.width(), - paint_rect.height(), - backing_store_dc, - paint_rect.x(), - paint_rect.y(), - SRCCOPY); - } - canvas.FillRect(color, gfx::Rect(gfx::Point(), paint_rect.size())); - skia::DrawToNativeContext(canvas.sk_canvas(), paint_dc, paint_rect.x(), - paint_rect.y(), NULL); -} - // The plugin wrapper window which lives in the browser process has this proc // as its window procedure. We only handle the WM_PARENTNOTIFY message sent by // windowed plugins for mouse input. This is forwarded off to the wrappers @@ -331,7 +306,6 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) weak_factory_(this), parent_hwnd_(NULL), is_loading_(false), - overlay_color_(0), text_input_type_(ui::TEXT_INPUT_TYPE_NONE), is_fullscreen_(false), ignore_mouse_movement_(true), @@ -870,19 +844,6 @@ void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { render_widget_host_->SetBackground(background); } -void RenderWidgetHostViewWin::SetVisuallyDeemphasized(const SkColor* color, - bool animate) { - // |animate| is not yet implemented, and currently isn't used. - CHECK(!animate); - - SkColor overlay_color = color ? *color : 0; - if (overlay_color_ == overlay_color) - return; - overlay_color_ = overlay_color; - - InvalidateRect(NULL, FALSE); -} - void RenderWidgetHostViewWin::UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) { } @@ -1037,22 +998,15 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { for (DWORD i = 0; i < region_data->rdh.nCount; ++i) { gfx::Rect paint_rect = bitmap_rect.Intersect(gfx::Rect(region_rects[i])); if (!paint_rect.IsEmpty()) { - if (SkColorGetA(overlay_color_) > 0) { - DrawDeemphasized(overlay_color_, - paint_rect, - backing_store->hdc(), - paint_dc.m_hDC); - } else { - BitBlt(paint_dc.m_hDC, - paint_rect.x(), - paint_rect.y(), - paint_rect.width(), - paint_rect.height(), - backing_store->hdc(), - paint_rect.x(), - paint_rect.y(), - SRCCOPY); - } + BitBlt(paint_dc.m_hDC, + paint_rect.x(), + paint_rect.y(), + paint_rect.width(), + paint_rect.height(), + backing_store->hdc(), + paint_rect.x(), + paint_rect.y(), + SRCCOPY); } } diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index 0424f7a..2224b55 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -193,8 +193,6 @@ class RenderWidgetHostViewWin virtual BackingStore* AllocBackingStore(const gfx::Size& size) OVERRIDE; virtual void OnAcceleratedCompositingStateChange() OVERRIDE; virtual void SetBackground(const SkBitmap& background) OVERRIDE; - virtual void SetVisuallyDeemphasized(const SkColor* color, - bool animate) OVERRIDE; virtual void UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) OVERRIDE; virtual void SetHasHorizontalScrollbar( @@ -462,10 +460,6 @@ class RenderWidgetHostViewWin // The time it took after this view was selected for it to be fully painted. base::TimeTicks tab_switch_paint_time_; - // A color we use to shade the entire render view. If 100% transparent, we do - // not shade the render view. - SkColor overlay_color_; - // Registrar so we can listen to RENDERER_PROCESS_TERMINATED events. content::NotificationRegistrar registrar_; diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 5f892f1..b8af6a3 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -126,8 +126,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE {} virtual gfx::Rect GetRootWindowBounds() OVERRIDE; #endif - virtual void SetVisuallyDeemphasized(const SkColor* color, - bool animate) OVERRIDE { } virtual void UnhandledWheelEvent( const WebKit::WebMouseWheelEvent& event) OVERRIDE { } virtual void SetHasHorizontalScrollbar( |